From 346f969f7926673e855220e5599f7deacc09b607 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Wed, 7 Jan 2026 18:29:58 +0000 Subject: [PATCH] Fix watch history sync speed, caching, and deletion bug --- js/historyView.js | 4 +++- js/nostr/watchHistory.js | 10 ++++++++++ js/ui/profileModalController.js | 4 ---- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/js/historyView.js b/js/historyView.js index 494f2399..5ef319dd 100644 --- a/js/historyView.js +++ b/js/historyView.js @@ -2400,7 +2400,9 @@ export function createWatchHistoryRenderer(config = {}) { showFeatureDisabledState(); return; } - await this.refresh({ ...options, force: true }); + // Use cached data immediately if available (force: false) unless overridden + const force = options.force === true; + await this.refresh({ ...options, force }); }, async ensureInitialLoad(options = {}) { if (!state.initialized) { diff --git a/js/nostr/watchHistory.js b/js/nostr/watchHistory.js index 4d06982b..f181be89 100644 --- a/js/nostr/watchHistory.js +++ b/js/nostr/watchHistory.js @@ -1640,6 +1640,16 @@ class WatchHistoryManager { WATCH_HISTORY_MAX_ITEMS, ); + // Ensure empty months are preserved so they get cleared on relays + if (cachedEntry.records && typeof cachedEntry.records === "object") { + const oldKeys = Object.keys(cachedEntry.records); + for (const oldKey of oldKeys) { + if (!records[oldKey]) { + records[oldKey] = []; + } + } + } + // Calculate fingerprint const fingerprint = await this.getFingerprint(resolvedActor, records); const flatItems = Object.values(records).flat(); diff --git a/js/ui/profileModalController.js b/js/ui/profileModalController.js index 1ea2be18..404330fa 100644 --- a/js/ui/profileModalController.js +++ b/js/ui/profileModalController.js @@ -5833,10 +5833,6 @@ export class ProfileModalController { try { await renderer.ensureInitialLoad({ actor: primaryActor }); - await renderer.refresh({ - actor: primaryActor, - force: true, - }); if (!this.boundProfileHistoryVisibility) { this.boundProfileHistoryVisibility = () => {