diff --git a/src/components/TimelineView.svelte b/src/components/TimelineView.svelte index d8ad717..dce9d22 100644 --- a/src/components/TimelineView.svelte +++ b/src/components/TimelineView.svelte @@ -65,11 +65,12 @@ try { await fetchTimeline(client, did, 7, showReplies); // only fetch interactions if logged in (because if not who is the interactor) - if (client.user) { + if (client.user && userDid) { if (!fetchingInteractions) { scheduledFetchInteractions = false; fetchingInteractions = true; - fetchInteractionsToTimelineEnd(client, did).finally(() => (fetchingInteractions = false)); + await fetchInteractionsToTimelineEnd(client, userDid, did); + fetchingInteractions = false; } else { scheduledFetchInteractions = true; } @@ -99,15 +100,17 @@ let fetchingInteractions = $state(false); let scheduledFetchInteractions = $state(false); - // we want to load interactions when changing logged in user on timelines + // we want to load interactions when changing logged in user // only on timelines that arent logged in users, because those are already // loaded by loadMore $effect(() => { - if (client && did && scheduledFetchInteractions && userDid !== did) { + if (client && scheduledFetchInteractions && userDid && did && did !== userDid) { if (!fetchingInteractions) { scheduledFetchInteractions = false; fetchingInteractions = true; - fetchInteractionsToTimelineEnd(client, did).finally(() => (fetchingInteractions = false)); + fetchInteractionsToTimelineEnd(client, userDid, did).finally( + () => (fetchingInteractions = false) + ); } else { scheduledFetchInteractions = true; } diff --git a/src/lib/result.ts b/src/lib/result.ts index 0cc3dc8..56e0ad0 100644 --- a/src/lib/result.ts +++ b/src/lib/result.ts @@ -12,7 +12,7 @@ export const ok = (value: T): Ok => { return { ok: true, value }; }; export const err = (error: E): Err => { - console.error(error); + // console.error(error); return { ok: false, error }; }; export const expect = (v: Result, msg: string = 'expected result to not be error:') => { diff --git a/src/lib/state.svelte.ts b/src/lib/state.svelte.ts index 87f9541..e757a53 100644 --- a/src/lib/state.svelte.ts +++ b/src/lib/state.svelte.ts @@ -512,12 +512,16 @@ export const fetchTimeline = async ( return newCursor; }; -export const fetchInteractionsToTimelineEnd = async (client: AtpClient, did: Did) => { - const cursor = postCursors.get(did); +export const fetchInteractionsToTimelineEnd = async ( + client: AtpClient, + interactor: Did, + subject: Did +) => { + const cursor = postCursors.get(subject); if (!cursor) return; const timestamp = timestampFromCursor(cursor.value); await Promise.all( - [likeSource, repostSource].map((s) => fetchLinksUntil(did, client, s, timestamp)) + [likeSource, repostSource].map((s) => fetchLinksUntil(interactor, client, s, timestamp)) ); };