diff --git a/src/components/TrendingNotes/index.tsx b/src/components/TrendingNotes/index.tsx
index 5dd4108..0e7e36d 100644
--- a/src/components/TrendingNotes/index.tsx
+++ b/src/components/TrendingNotes/index.tsx
@@ -53,6 +53,27 @@ export default function TrendingNotes() {
const isFetchingNostrRef = useRef(false)
const hasUserClickedNostrTabRef = useRef(false)
+ // Listen for tab restoration from PageManager
+ useEffect(() => {
+ const handleRestore = (e: CustomEvent<{ page: string, tab: string }>) => {
+ if (e.detail.page === 'search' && e.detail.tab && ['nostr', 'relays', 'hashtags'].includes(e.detail.tab)) {
+ // If restoring to 'nostr' tab, mark it as clicked and clear events to force a fresh load
+ if (e.detail.tab === 'nostr') {
+ hasUserClickedNostrTabRef.current = true
+ // Clear any existing events and error state to force a fresh load (only for API tab)
+ setNostrEvents([])
+ setNostrError(null)
+ }
+ // For 'relays' and 'hashtags' tabs, just set the active tab
+ // The cache should already be loaded, but if it's empty, the initialization useEffect will handle it
+ // Then set the active tab - this will trigger the useEffect that loads the feed
+ setActiveTab(e.detail.tab as TrendingTab)
+ }
+ }
+ window.addEventListener('restorePageTab', handleRestore as EventListener)
+ return () => window.removeEventListener('restorePageTab', handleRestore as EventListener)
+ }, [])
+
// Load Nostr.band trending feed only when user explicitly clicks the nostr tab
useEffect(() => {
const loadTrending = async () => {
@@ -588,7 +609,12 @@ export default function TrendingNotes() {
Trending: