From 2c12b822fb51f5c9ec9f7c06b05c9a0984bec2f1 Mon Sep 17 00:00:00 2001 From: Silberengel Date: Tue, 24 Mar 2026 07:17:47 +0100 Subject: [PATCH] speed up feeds --- src/components/CacheRelaysSetting/index.tsx | 38 ++- .../Explore/ExploreRelayReviews.tsx | 4 +- src/components/NoteList/index.tsx | 8 +- src/constants.ts | 10 +- .../primary/NoteListPage/FollowingFeed.tsx | 42 ++- src/pages/primary/NoteListPage/RelaysFeed.tsx | 49 ++-- .../secondary/ProfileEditorPage/index.tsx | 20 +- src/providers/NostrProvider/index.tsx | 270 ++++++++++++------ src/providers/nostr-context.tsx | 5 + src/services/client.service.ts | 139 +++++++-- src/services/local-storage.service.ts | 24 ++ 11 files changed, 444 insertions(+), 165 deletions(-) diff --git a/src/components/CacheRelaysSetting/index.tsx b/src/components/CacheRelaysSetting/index.tsx index 07834853..8128d527 100644 --- a/src/components/CacheRelaysSetting/index.tsx +++ b/src/components/CacheRelaysSetting/index.tsx @@ -41,12 +41,21 @@ import { Drawer, DrawerContent, DrawerHeader, DrawerTitle, DrawerDescription } f import { HoverCard, HoverCardContent, HoverCardTrigger } from '@/components/ui/hover-card' import { useScreenSize } from '@/providers/ScreenSizeProvider' import { toast } from 'sonner' +import { syncUserDeletionTombstones } from '@/lib/sync-user-deletions' import { Event } from 'nostr-tools' export default function CacheRelaysSetting() { const { t } = useTranslation() const { isSmallScreen } = useScreenSize() - const { pubkey, cacheRelayListEvent, checkLogin, publish, updateCacheRelayListEvent } = useNostr() + const { + pubkey, + cacheRelayListEvent, + checkLogin, + publish, + updateCacheRelayListEvent, + relayList, + requestAccountNetworkHydrate + } = useNostr() const [relays, setRelays] = useState([]) const [hasChange, setHasChange] = useState(false) const [pushing, setPushing] = useState(false) @@ -62,6 +71,7 @@ export default function CacheRelaysSetting() { const [showConsoleLogs, setShowConsoleLogs] = useState(false) const [consoleLogSearch, setConsoleLogSearch] = useState('') const [consoleLogLevel, setConsoleLogLevel] = useState<'errors-warnings' | 'all'>('all') + const [cacheRefreshBusy, setCacheRefreshBusy] = useState(false) const consoleLogRef = useRef; timestamp: number }>>([]) const sensors = useSensors( @@ -282,16 +292,19 @@ export default function CacheRelaysSetting() { const handleRefreshCache = async () => { try { - // Force database upgrade to update structure + setCacheRefreshBusy(true) await indexedDb.forceDatabaseUpgrade() - - // Reload cache info await loadCacheInfo() - + if (pubkey) { + await requestAccountNetworkHydrate() + await syncUserDeletionTombstones(pubkey, relayList) + } toast.success(t('Cache refreshed successfully')) } catch (error) { logger.error('Failed to refresh cache', { error }) toast.error(t('Failed to refresh cache')) + } finally { + setCacheRefreshBusy(false) } } @@ -848,14 +861,25 @@ export default function CacheRelaysSetting() {

{t('In-Browser Cache')}

{t('Clear cached data stored in your browser, including IndexedDB events, localStorage settings, and service worker caches.')}
+
+ {t('refreshCacheButtonExplainer', { + defaultValue: + 'Refresh Cache runs an IndexedDB upgrade check, re-fetches your relay lists and profile-related events from the network (same work as the automatic startup sync), syncs kind-5 deletions into tombstones and removes deleted items from the local cache, then refreshes the store counts below.' + })} +
-