Fix review perf issues.
This commit is contained in:
+10
-11
@@ -373,21 +373,20 @@ export default function App() {
|
||||
}, []);
|
||||
|
||||
// Live updates. Every event on this stream is about this review — the stream is
|
||||
// the tab's own — so anything that isn't the opening handshake means the comment
|
||||
// list moved and is worth refetching.
|
||||
// the tab's own — so anything that arrives means the comment list moved and is
|
||||
// worth refetching.
|
||||
//
|
||||
// The handshake refetches too, which it did not used to. The stream is dropped
|
||||
// while the pane is hidden (see useSSE) and reconnects when it comes back, so
|
||||
// `connected` is the one moment the rail is known to be behind: every comment
|
||||
// written while this pane was off screen is a frame nobody was listening for.
|
||||
// Treating the handshake as "something changed" is what closes that gap — and
|
||||
// the same gap after a dropped connection, which was always there.
|
||||
//
|
||||
// Comments only. The diff is not pushed: the server has no watcher on the work
|
||||
// tree, and a comment arriving is a change to the rail, which can be applied
|
||||
// under the reader safely. A changed *diff* cannot — see the poll below.
|
||||
useSSE(
|
||||
useCallback(
|
||||
(e) => {
|
||||
if (e.type === 'connected') return;
|
||||
refetchComments();
|
||||
},
|
||||
[refetchComments],
|
||||
),
|
||||
);
|
||||
useSSE(useCallback(() => refetchComments(), [refetchComments]));
|
||||
|
||||
// Notice that the diff on screen has been overtaken, and say so. Nothing here
|
||||
// reloads anything: it sets `stale`, the banner offers the refresh, and the
|
||||
|
||||
Reference in New Issue
Block a user