fix interactions not loading on other users profiles
63 unmodified lines6465666768686970717272737475767721 unmodified lines99100101102102103104105106106107108109110110111112113114115116117115 unmodified linesExpand all63 unmodified lines
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; } }21 unmodified lines });
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; } }115 unmodified linesExpand all10 unmodified lines1112131415151617181913 unmodified lines10 unmodified linesexport const ok = <T>(value: T): Ok<T> => { return { ok: true, value };};export const err = <E>(error: E): Err<E> => { console.error(error); // console.error(error); return { ok: false, error };};export const expect = <T, E>(v: Result<T, E>, msg: string = 'expected result to not be error:') => { if (v.ok) {13 unmodified lines510 unmodified linesExpand all511512513514515516515516517518519520521522523520524525526527528118 unmodified linesExpand all510 unmodified linesExpand all console.log(`${subject}: fetchTimeline`, accPosts.value.cursor); 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)) );};
export const fetchInitial = async (account: Account) => {118 unmodified linesExpand all