Define centralized cache policies and wire them into fetchers

This commit is contained in:
google-labs-jules[bot] committed 2026-01-17 19:12:09 +00:00
1 parent cb87d556a1
commit 86ffb8cb2a
8 files changed
+216 -6

No files matched your search

+9
View File
@@ -18,6 +18,7 @@ import {
getNostrEventSchema,
NOTE_TYPES,
} from "./nostrEventSchemas.js";
import { CACHE_POLICIES, STORAGE_TIERS } from "./nostr/cachePolicies.js";
import { getSidebarLoadingMarkup } from "./sidebarLoading.js";
import {
publishEventToRelays,
@@ -277,6 +278,10 @@ class SubscriptionsManager {
}
loadFromCache(userPubkey) {
const policy = CACHE_POLICIES[NOTE_TYPES.SUBSCRIPTION_LIST];
if (policy?.storage !== STORAGE_TIERS.LOCAL_STORAGE) {
return null;
}
if (typeof localStorage === "undefined") return null;
const key = this.getCacheKey(userPubkey);
if (!key) return null;
@@ -294,6 +299,10 @@ class SubscriptionsManager {
}
saveToCache(userPubkey) {
const policy = CACHE_POLICIES[NOTE_TYPES.SUBSCRIPTION_LIST];
if (policy?.storage !== STORAGE_TIERS.LOCAL_STORAGE) {
return;
}
if (typeof localStorage === "undefined") return;
const key = this.getCacheKey(userPubkey);
if (!key) return;