From b9406aa011db2db7d3bcdf7d91ef929b17a07c02 Mon Sep 17 00:00:00 2001 From: dan Date: Sun, 24 Nov 2024 19:10:54 +0000 Subject: Don't re-sort already fetched post thread items (#6698) * Don't reorder already seen posts in PostThread * Add sorting by generation * Rip out stable order cache It doesn't make sense because sort() doesn't call the callback for all A/B pairs, and the server returning a different ordering will cause cache misses which means there'll be no stability anyway. * Make hotness deterministic per fetched at * Cache random scores while in thread * Reorder for clarity --- src/view/com/post-thread/PostThread.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/view/com/post-thread/PostThread.tsx') diff --git a/src/view/com/post-thread/PostThread.tsx b/src/view/com/post-thread/PostThread.tsx index 7ce6deaa1..315800fe5 100644 --- a/src/view/com/post-thread/PostThread.tsx +++ b/src/view/com/post-thread/PostThread.tsx @@ -104,6 +104,7 @@ export function PostThread({uri}: {uri: string | undefined}) { error: threadError, refetch, data: {thread, threadgate} = {}, + dataUpdatedAt: fetchedAt, } = usePostThreadQuery(uri) const treeView = React.useMemo( @@ -171,6 +172,8 @@ export function PostThread({uri}: {uri: string | undefined}) { () => new Set(), ) + const [fetchedAtCache] = React.useState(() => new Map()) + const [randomCache] = React.useState(() => new Map()) const skeleton = React.useMemo(() => { const threadViewPrefs = preferences?.threadViewPrefs if (!threadViewPrefs || !thread) return null @@ -183,6 +186,9 @@ export function PostThread({uri}: {uri: string | undefined}) { currentDid, justPostedUris, threadgateHiddenReplies, + fetchedAtCache, + fetchedAt, + randomCache, ), currentDid, treeView, @@ -199,6 +205,9 @@ export function PostThread({uri}: {uri: string | undefined}) { hiddenRepliesState, justPostedUris, threadgateHiddenReplies, + fetchedAtCache, + fetchedAt, + randomCache, ]) const error = React.useMemo(() => { -- cgit 1.4.1