fix initial loading on timelines
8 unmodified lines910111213131415161718102 unmodified linesExpand all1211221231241241251261271288 unmodified lines followingFeed, accountPreferences, fetchInteractionsToFollowingTimelineEnd, follows, followingCursors followingCursors, initialDone } from '$lib/state.svelte'; import { buildThreads, filterThreads } from '$lib/thread'; import type { Did } from '@atcute/lexicons/syntax'; import GenericTimelineView from './GenericTimelineView.svelte';102 unmodified linesExpand all {threads} bind:postComposerState class={className} isLoggedIn={!!(userDid || $accounts.length > 0)} canLoad={!!(client && userDid)} canLoad={!!(client && userDid && initialDone.has(userDid))} onLoadMore={loadMore} {isComplete}/>123455678911101112131415161718192015 unmodified lines3637383940404142437 unmodified lines51525354565758596055565758596030 unmodified lines91929394959697989910010110210310410510610710889 unmodified lines<script lang="ts"> import BskyPost from './BskyPost.svelte'; import { type State as PostComposerState } from './PostComposer.svelte'; import { AtpClient } from '$lib/at/client.svelte'; import { accounts } from '$lib/accounts'; import { type ResourceUri } from '@atcute/lexicons'; import { SvelteSet } from 'svelte/reactivity'; import { InfiniteLoader, LoaderState } from 'svelte-infinite'; import Icon from '@iconify/svelte'; import { type ThreadPost, type Thread } from '$lib/thread'; import type { Did } from '@atcute/lexicons/syntax'; import NotLoggedIn from './NotLoggedIn.svelte'; import LoadingSpinner from './LoadingSpinner.svelte'; import EndOfList from './EndOfList.svelte'; import LoadError from './LoadError.svelte'; import LoadNewPosts from './LoadNewPosts.svelte'; import { onMount } from 'svelte'; import { initialDone } from '$lib/state.svelte';
interface Props { client?: AtpClient | null; threads: Thread[];15 unmodified lines onLoadMore, isComplete = false }: Props = $props();
// Default canLoad to isLoggedIn if not provided, for backward compatibility/simpler usage const shouldLoad = $derived(canLoad ?? isLoggedIn);
let reverseChronological = $state(true); const expandedThreads = new SvelteSet<ResourceUri>();7 unmodified lines });
$effect(() => { if (threads.length > 0) { if (isAtTop) { boundaryTime = threads[0].newestTime; } else if (boundaryTime === null) { boundaryTime = threads[0].newestTime; } if (isAtTop) boundaryTime = threads[0].newestTime; else if (boundaryTime === null) boundaryTime = threads[0].newestTime; } });
const showNewPosts = () => {30 unmodified lines $effect(() => { const isEmpty = threads.length < 15; if (isEmpty && !loading && shouldLoad && !isComplete) loadMore(); });
$effect(() => { if (!initialDone.has(client?.user?.did ?? 'did:plc:invalid')) { loading = true; loaderState.status = 'LOADING'; } else { loading = false; loaderState.loaded(); } });</script>
<svelte:window onscroll={onScroll} />
89 unmodified lines965 unmodified linesExpand all9669679689699709719729739741 unmodified line976977978979980981982983984119 unmodified linesExpand all965 unmodified linesExpand all [likeSource, repostSource].map((s) => fetchLinksUntil(userDid, client, s, minTimestamp)) );};
export const initialDone = new SvelteSet<Did>();export const fetchInitial = async (account: Account) => { const client = clients.get(account.did)!; await Promise.all([ fetchBlocks(account),1 unmodified line fetchFollows(account).then((follows) => Promise.all(follows.map((follow) => fetchForInteractions(client, follow.subject)) ?? []) ) ]); initialDone.add(account.did);};
export const handleJetstreamEvent = async (event: JetstreamEvent) => { if (event.kind !== 'commit') return;119 unmodified linesExpand all