2024-06-17 21:17:27 +01:00
|
|
|
<script>
|
2024-07-02 19:38:20 +01:00
|
|
|
import { page } from '$app/stores';
|
2024-07-07 14:33:28 +01:00
|
|
|
import { account } from '$lib/stores/account.js';
|
2024-07-02 19:38:20 +01:00
|
|
|
import { timeline, getTimeline } from '$lib/timeline.js';
|
2025-07-13 18:35:26 +01:00
|
|
|
import Lang from '$lib/lang.js';
|
2024-07-01 03:41:02 +01:00
|
|
|
|
|
|
|
import LoginForm from '$lib/ui/LoginForm.svelte';
|
2024-07-07 12:22:29 +01:00
|
|
|
import Button from '$lib/ui/Button.svelte';
|
|
|
|
import Post from '$lib/ui/post/Post.svelte';
|
2024-07-02 19:38:20 +01:00
|
|
|
|
2025-07-13 18:35:26 +01:00
|
|
|
const lang = Lang('en_GB');
|
|
|
|
|
2024-07-07 14:33:28 +01:00
|
|
|
account.subscribe(account => {
|
|
|
|
if (account) getTimeline();
|
2024-07-02 20:21:34 +01:00
|
|
|
});
|
2024-07-07 12:22:29 +01:00
|
|
|
|
|
|
|
document.addEventListener("scroll", () => {
|
2024-07-07 14:58:59 +01:00
|
|
|
if ($account && $page.url.pathname !== "/") return;
|
2024-07-02 19:38:20 +01:00
|
|
|
if (window.innerHeight + window.scrollY >= document.body.offsetHeight - 2048) {
|
|
|
|
getTimeline();
|
|
|
|
}
|
|
|
|
});
|
2024-06-17 21:17:27 +01:00
|
|
|
</script>
|
|
|
|
|
2024-07-07 14:33:28 +01:00
|
|
|
{#if $account}
|
2024-07-07 12:22:29 +01:00
|
|
|
<header>
|
2025-07-13 18:35:26 +01:00
|
|
|
<h1>{lang.string('timeline.home')}</h1>
|
2024-07-07 12:22:29 +01:00
|
|
|
<nav>
|
2025-07-13 18:35:26 +01:00
|
|
|
<Button centered active>{lang.string('timeline.home')}</Button>
|
|
|
|
<Button centered disabled>{lang.string('timeline.local')}</Button>
|
|
|
|
<Button centered disabled>{lang.string('timeline.federated')}</Button>
|
2024-07-07 12:22:29 +01:00
|
|
|
</nav>
|
|
|
|
</header>
|
|
|
|
|
|
|
|
<div id="feed" role="feed">
|
|
|
|
{#if $timeline.length <= 0}
|
|
|
|
<div class="loading throb">
|
2025-07-13 18:35:26 +01:00
|
|
|
<span>{lang.string('timeline.fetching')}</span>
|
2024-07-07 12:22:29 +01:00
|
|
|
</div>
|
|
|
|
{/if}
|
|
|
|
{#each $timeline as post}
|
|
|
|
<Post post_data={post} />
|
|
|
|
{/each}
|
|
|
|
</div>
|
2024-06-29 23:10:29 +01:00
|
|
|
{:else}
|
2024-07-01 03:41:02 +01:00
|
|
|
<LoginForm />
|
2024-06-29 17:27:46 +01:00
|
|
|
{/if}
|
2024-06-17 21:17:27 +01:00
|
|
|
|
|
|
|
<style>
|
2024-06-29 17:27:46 +01:00
|
|
|
header {
|
2024-06-29 14:48:34 +01:00
|
|
|
width: 100%;
|
2024-07-07 12:22:29 +01:00
|
|
|
height: 64px;
|
2025-07-13 16:50:15 +01:00
|
|
|
margin: 16px 0;
|
|
|
|
padding: 0 8px;
|
2024-06-29 14:48:34 +01:00
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
2025-07-10 18:11:49 +01:00
|
|
|
user-select: none;
|
2025-07-13 16:50:15 +01:00
|
|
|
box-sizing: border-box;
|
|
|
|
|
2024-06-29 14:48:34 +01:00
|
|
|
}
|
|
|
|
|
2024-06-29 17:27:46 +01:00
|
|
|
header h1 {
|
2024-06-29 14:48:34 +01:00
|
|
|
font-size: 1.5em;
|
|
|
|
}
|
|
|
|
|
2024-07-07 12:22:29 +01:00
|
|
|
nav {
|
2024-06-29 14:48:34 +01:00
|
|
|
margin-left: auto;
|
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
2025-07-10 22:32:54 +01:00
|
|
|
align-items: center;
|
2024-06-29 14:48:34 +01:00
|
|
|
gap: 8px;
|
|
|
|
}
|
2024-06-29 15:24:33 +01:00
|
|
|
|
2024-07-07 12:22:29 +01:00
|
|
|
#feed {
|
|
|
|
margin-bottom: 20vh;
|
|
|
|
}
|
|
|
|
|
|
|
|
.loading {
|
|
|
|
width: 100%;
|
|
|
|
height: 80vh;
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
font-size: 2em;
|
|
|
|
font-weight: bold;
|
2024-06-29 15:24:33 +01:00
|
|
|
}
|
2024-06-17 21:17:27 +01:00
|
|
|
</style>
|