perf(watch-history): eagerly preload on login (was lazy until For You/history tab)

Watch history was never loaded as part of the login cascade — it only loaded
when the For You feed refreshed or the history tab was opened. So on login (and
on other feeds) watched-video suppression and watch-history tags did nothing
until the user navigated there.

Kick off a non-blocking watchHistoryService.loadLatest() during the login
list-sync (deliberately NOT in parallelListTasks, so the feed never waits for
it). loadLatest schedules the background refresh, which emits "fingerprint" and
the For You feed re-runs (feedCoordinator) to apply suppression once resolved.
Deduped against the feed's own loadLatest via the in-flight refresh promise.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
thePR0M3TH3ANandClaude Opus 4.8 committed 2026-06-12 14:18:09 -04:00
1 parent 9b12a282af
commit 0c8a17e3cf
1 file changed
+21
+21
View File
@@ -11,6 +11,7 @@
import { clearDecryptionSchemeCache } from "../nostr/decryptionSchemeCache.js";
import { clearWatchHistoryConversationKeyCache } from "../nostr/watchHistory.js";
import watchHistoryService from "../watchHistoryService.js";
import { FEED_TYPES } from "../constants.js";
/**
@@ -419,6 +420,26 @@ export function createAuthSessionCoordinator(deps) {
const parallelListTasks = [];
// Eagerly warm watch history in the background on login (NOT awaited /
// not in parallelListTasks — the feed must never wait for it). loadLatest
// schedules the background refresh, which emits "fingerprint" so the For
// You feed re-runs (see feedCoordinator) to suppress watched videos.
// Without this it only loaded when For You or the history tab was opened.
if (
activePubkey &&
watchHistoryService &&
typeof watchHistoryService.loadLatest === "function"
) {
Promise.resolve(
watchHistoryService.loadLatest(activePubkey, { allowStale: true }),
).catch((error) => {
devLogger.warn(
"[auth] Background watch-history preload failed:",
error,
);
});
}
if (
activePubkey &&
typeof this.authService.loadBlocksForPubkey === "function"