mirror of
https://github.com/block/buzz.git
synced 2026-08-18 06:50:31 +02:00
perf(desktop): retain channel page provenance with warm rows
Keep the authoritative channel window alive for the same hour as its projected message cache so revisits cannot lose loader provenance first. Co-authored-by: Carl <c7ebe626f000404285d3686e1dc74cc07cc60a9754a150041ba132e14bd3e2ec@buzz.block.builderlab.xyz> Signed-off-by: Wes <wesbillman@users.noreply.github.com>
This commit is contained in:
@@ -228,6 +228,8 @@ export function resolveThreadReplyTarget(
|
||||
};
|
||||
}
|
||||
|
||||
export const CHANNEL_TIMELINE_GC_TIME_MS = 60 * 60 * 1_000;
|
||||
|
||||
export function useChannelWindowQuery(channel: Channel | null) {
|
||||
const queryClient = useQueryClient();
|
||||
const queryKey = channelWindowKey(channel?.id ?? "none");
|
||||
@@ -238,6 +240,9 @@ export function useChannelWindowQuery(channel: Channel | null) {
|
||||
queryClient.getQueryData<ChannelWindowStore>(queryKey) ??
|
||||
emptyChannelWindowStore(),
|
||||
staleTime: Number.POSITIVE_INFINITY,
|
||||
// Page provenance determines whether cached rows (including known-empty)
|
||||
// are warm enough to paint. Retain it for exactly as long as those rows.
|
||||
gcTime: CHANNEL_TIMELINE_GC_TIME_MS,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -368,7 +373,7 @@ export function useChannelMessagesQuery(channel: Channel | null) {
|
||||
);
|
||||
},
|
||||
staleTime: 5 * 60 * 1_000,
|
||||
gcTime: 60 * 60 * 1_000,
|
||||
gcTime: CHANNEL_TIMELINE_GC_TIME_MS,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ import test from "node:test";
|
||||
import { QueryClient, QueryObserver } from "@tanstack/react-query";
|
||||
|
||||
import {
|
||||
CHANNEL_TIMELINE_GC_TIME_MS,
|
||||
reconcileFetchedChannelWindow,
|
||||
reconcileFetchedChannelWindowPages,
|
||||
} from "../hooks.ts";
|
||||
@@ -54,6 +55,10 @@ function newestPage(rows) {
|
||||
};
|
||||
}
|
||||
|
||||
test("channel page provenance is retained for the full warm-row lifetime", () => {
|
||||
assert.equal(CHANNEL_TIMELINE_GC_TIME_MS, 60 * 60 * 1_000);
|
||||
});
|
||||
|
||||
function createHarness() {
|
||||
const client = new QueryClient({
|
||||
defaultOptions: { queries: { retry: false } },
|
||||
|
||||
Reference in New Issue
Block a user