Persist feed tab across navigation — back button returns to correct tab

Feed tab (Global/Following) moved from local state to UI store so it
survives thread/profile navigation. Fixed hardcoded "feed" in openThread
calls to pass currentView instead.
This commit is contained in:
Jure
2026-03-14 16:23:51 +01:00
parent 3ca73a8b01
commit ef35f20688
4 changed files with 10 additions and 7 deletions

View File

@@ -3,6 +3,7 @@ import { create } from "zustand";
import { NDKEvent } from "@nostr-dev-kit/ndk";
type View = "feed" | "search" | "relays" | "settings" | "profile" | "thread" | "article-editor" | "article" | "about" | "zaps" | "dm" | "notifications";
type FeedTab = "global" | "following";
interface UIState {
currentView: View;
@@ -10,11 +11,13 @@ interface UIState {
selectedPubkey: string | null;
selectedNote: NDKEvent | null;
previousView: View;
feedTab: FeedTab;
pendingSearch: string | null;
pendingDMPubkey: string | null;
pendingArticleNaddr: string | null;
showHelp: boolean;
setView: (view: View) => void;
setFeedTab: (tab: FeedTab) => void;
openProfile: (pubkey: string) => void;
openThread: (note: NDKEvent, from: View) => void;
openSearch: (query: string) => void;
@@ -33,11 +36,13 @@ export const useUIStore = create<UIState>((set, _get) => ({
selectedPubkey: null,
selectedNote: null,
previousView: "feed",
feedTab: "global",
pendingSearch: null,
pendingDMPubkey: null,
pendingArticleNaddr: null,
showHelp: false,
setView: (currentView) => set({ currentView }),
setFeedTab: (feedTab) => set({ feedTab }),
openProfile: (pubkey) => set((s) => ({ currentView: "profile", selectedPubkey: pubkey, previousView: s.currentView as View })),
openThread: (note, from) => set({ currentView: "thread", selectedNote: note, previousView: from }),
openSearch: (query) => set({ currentView: "search", pendingSearch: query }),