Revert "perf(watch-history): decrypt only recent months on load (cap cold cost)"

This reverts commit b5ad582b6c.
This commit is contained in:
thePR0M3TH3AN committed 2026-06-12 21:21:16 -04:00
1 parent b5ad582b6c
commit 9dddda0326
4 files changed
+2 -24

No files matched your search

-3
View File
@@ -1521,12 +1521,9 @@ export function createWatchHistoryRenderer(config = {}) {
);
}
}
// The History view shows the user's FULL history (all months), unlike the
// feed's automatic load which only decrypts recent months for speed.
const items = await watchHistoryService.loadLatest(actorInput, {
allowStale: !forceRefresh,
forceRefresh,
recentMonthsLimit: 0,
});
const normalized = normalizeHistoryItems(items);
return { items: normalized, metadata: { engine: "service-fallback" } };
-16
View File
@@ -41,10 +41,6 @@ import {
export { normalizePointerInput, pointerKey };
// Recent monthly watch-history snapshots to decrypt on load (1 nip-07 call each).
// Override per-call with recentMonthsLimit (0 = all, e.g. the History view).
const RECENT_MONTHS_DECRYPT_LIMIT = 6;
/**
* Domain utilities for watch-history interactions. This module owns pointer
* normalization/serialization, chunking, fingerprint hashing, persistence,
@@ -1993,17 +1989,6 @@ class WatchHistoryManager {
return await loadFromStorage();
}
// Decrypt only the most recent months by default (see constant above).
const recentMonthsLimit = Number.isFinite(options?.recentMonthsLimit)
? Math.floor(options.recentMonthsLimit)
: RECENT_MONTHS_DECRYPT_LIMIT;
if (recentMonthsLimit > 0 && pointerEvents.length > recentMonthsLimit) {
pointerEvents = [...pointerEvents]
.sort((a, b) => (b?.created_at || 0) - (a?.created_at || 0))
.slice(0, recentMonthsLimit);
eventToProcess = pointerEvents;
}
// Determine snapshotId from the latest event (prioritizing monthly)
const latestEvent = selectNewestListEvent(eventToProcess);
@@ -2232,7 +2217,6 @@ class WatchHistoryManager {
const fetchResult = await this.fetch(resolvedActor, {
forceRefresh: options.forceRefresh || false,
recentMonthsLimit: options.recentMonthsLimit,
});
const merged = mergeWatchHistoryItemsWithFallback(
{
+1 -4
View File
@@ -1015,10 +1015,7 @@ function scheduleWatchHistoryRefresh(actorKey, cacheEntry = {}, options = {}) {
if (!permissionResult.ok) {
throw permissionResult.error;
}
return nostrClient.resolveWatchHistory(actorKey, {
forceRefresh: true,
recentMonthsLimit: options?.recentMonthsLimit,
});
return nostrClient.resolveWatchHistory(actorKey, { forceRefresh: true });
})()
.then((resolvedItems) => updateFingerprintCache(actorKey, resolvedItems))
.then(() => {
+1 -1
View File
@@ -39,7 +39,7 @@ const GRANDFATHERED = {
"js/subscriptions.js": 2426,
"js/userBlocks.js": 2353,
"js/services/nostrService.js": 2227,
"js/nostr/watchHistory.js": 2360,
"js/nostr/watchHistory.js": 2335,
"js/nostr/nip46Client.js": 2102,
"js/state/cache.js": 1827,
"js/app/feedCoordinator.js": 1767,