···
if ($accounts.length > 0) {
+
loaderState.status = 'LOADING';
selectedDid = $accounts[0].did;
Promise.all($accounts.map(loginAccount)).then(() => {
···
let posts = new SvelteMap<Did, SvelteMap<ResourceUri, AppBskyFeedPost.Main>>();
+
let cursors = new SvelteMap<Did, { value?: string; end: boolean }>();
const fetchTimeline = async (account: Account) => {
const client = clients.get(account.did);
const cursor = cursors.get(account.did);
+
if (cursor && cursor.end) return;
+
const accPosts = await fetchPostsWithBacklinks(client, account.did, cursor?.value, 6);
throw `failed to fetch posts for account ${account.handle}: ${accPosts.error}`;
+
// if the cursor is undefined, we've reached the end of the timeline
+
if (!accPosts.value.cursor) {
+
cursors.set(account.did, { ...cursor, end: true });
+
cursors.set(account.did, { value: accPosts.value.cursor, end: false });
const accTimeline = await hydratePosts(client, accPosts.value.posts);
if (!posts.has(account.did)) {
posts.set(account.did, new SvelteMap(accTimeline));
···
+
if (cursors.values().every((cursor) => cursor.end)) loaderState.complete();
···
+
if (!childrenMap.has(post.parentUri)) childrenMap.set(post.parentUri, []);
childrenMap.get(post.parentUri)!.push(post);
// Sort children by time (newest first)
+
.forEach((children) => children.sort((a, b) => b.newestTime - a.newestTime));
// Helper to create a thread from posts
···
const addWithChildren = (post: ThreadPost) => {
const children = childrenMap.get(post.uri) || [];
+
children.forEach(addWithChildren);
addWithChildren(startPost);
···
<div class="mt-4 overflow-y-scroll [scrollbar-width:none]" bind:this={scrollContainer}>
+
{#if $accounts.length > 0}
+
{@render renderThreads()}
+
<div class="flex justify-center py-4">
+
<p class="text-xl opacity-80" style="color: {theme.fg};">
+
<span class="text-4xl">x_x</span> <br /> no accounts are logged in!
+
{#snippet renderThreads()}
+
loopDetectionTimeout={0}
+
intersectionOptions={{ root: scrollContainer }}
+
{@render threadsView()}
+
<div class="flex justify-center py-4">
+
<p class="text-xl opacity-80" style="color: {theme.fg};">
+
all posts seen! <span class="text-2xl">:o</span>
+
<div class="flex justify-center">
+
class="h-12 w-12 animate-spin rounded-full border-4 border-t-transparent"
+
style="border-color: {theme.accent} {theme.accent} {theme.accent} transparent;"
+
<div class="flex justify-center py-4">
+
<p class="text-xl opacity-80" style="color: {theme.fg};">
+
<span class="text-4xl">:(</span> <br /> an error occurred while loading posts: {loadError}
{#each threads as thread (thread.rootUri)}
<div class="flex {reverseChronological ? 'flex-col' : 'flex-col-reverse'} mb-6.5">
{#if thread.branchParentPost}
{@const post = thread.branchParentPost}
<div class="mb-1.5 flex items-center gap-1.5">
+
<span class="text-sm text-nowrap opacity-60" style="color: {theme.fg};"
>{reverseChronological ? '↱' : '↳'}</span