diff --git a/src/components/feed/Feed.tsx b/src/components/feed/Feed.tsx index ffefe3d..03d3222 100644 --- a/src/components/feed/Feed.tsx +++ b/src/components/feed/Feed.tsx @@ -2,19 +2,17 @@ import { useEffect, useState } from "react"; import { useFeedStore } from "../../stores/feed"; import { useUserStore } from "../../stores/user"; import { useMuteStore } from "../../stores/mute"; +import { useUIStore } from "../../stores/ui"; import { fetchFollowFeed, getNDK } from "../../lib/nostr"; import { NoteCard } from "./NoteCard"; import { ComposeBox } from "./ComposeBox"; import { NDKEvent } from "@nostr-dev-kit/ndk"; -type FeedTab = "global" | "following"; - export function Feed() { const { notes, loading, connected, error, connect, loadCachedFeed, loadFeed, focusedNoteIndex } = useFeedStore(); const { loggedIn, follows } = useUserStore(); const { mutedPubkeys } = useMuteStore(); - - const [tab, setTab] = useState("global"); + const { feedTab: tab, setFeedTab: setTab } = useUIStore(); const [followNotes, setFollowNotes] = useState([]); const [followLoading, setFollowLoading] = useState(false); diff --git a/src/components/feed/NoteCard.tsx b/src/components/feed/NoteCard.tsx index 480328f..3680729 100644 --- a/src/components/feed/NoteCard.tsx +++ b/src/components/feed/NoteCard.tsx @@ -191,7 +191,7 @@ export function NoteCard({ event, focused }: NoteCardProps) { onClick={async (e) => { e.stopPropagation(); const parent = await fetchNoteById(parentEventId); - if (parent) openThread(parent, "feed"); + if (parent) openThread(parent, currentView as "feed" | "profile"); }} className="hover:text-accent transition-colors" > diff --git a/src/components/feed/NoteContent.tsx b/src/components/feed/NoteContent.tsx index 7e0c2b7..1f8dca1 100644 --- a/src/components/feed/NoteContent.tsx +++ b/src/components/feed/NoteContent.tsx @@ -173,7 +173,7 @@ function tryOpenNostrEntity(raw: string): boolean { function QuotePreview({ eventId }: { eventId: string }) { const [event, setEvent] = useState(null); - const { openThread } = useUIStore(); + const { openThread, currentView } = useUIStore(); const profile = useProfile(event?.pubkey ?? ""); useEffect(() => { @@ -189,7 +189,7 @@ function QuotePreview({ eventId }: { eventId: string }) { return (
{ e.stopPropagation(); openThread(event, "feed"); }} + onClick={(e) => { e.stopPropagation(); openThread(event, currentView as "feed" | "profile"); }} >
{profile?.picture && ( diff --git a/src/stores/ui.ts b/src/stores/ui.ts index 407f75c..f4a68fc 100644 --- a/src/stores/ui.ts +++ b/src/stores/ui.ts @@ -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((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 }),