mirror of
https://github.com/hoornet/vega.git
synced 2026-05-11 14:41:18 -07:00
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:
@@ -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 }),
|
||||
|
||||
Reference in New Issue
Block a user