Add thread view with replies

- Click note content to open thread view
- ThreadView shows root note, reply composer, and replies
- fetchReplies added to nostr lib (kind 1 #e filter)
- UI store gains openThread, goBack, previousView for navigation history
- Profile back button now returns to previous view correctly

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jure
2026-03-08 18:55:57 +01:00
parent 30b5bb8d42
commit 366731f9d7
7 changed files with 183 additions and 8 deletions

View File

@@ -1,21 +1,31 @@
import { create } from "zustand";
type View = "feed" | "relays" | "settings" | "profile";
import { NDKEvent } from "@nostr-dev-kit/ndk";
type View = "feed" | "relays" | "settings" | "profile" | "thread";
interface UIState {
currentView: View;
sidebarCollapsed: boolean;
selectedPubkey: string | null;
selectedNote: NDKEvent | null;
previousView: View;
setView: (view: View) => void;
openProfile: (pubkey: string) => void;
openThread: (note: NDKEvent, from: View) => void;
goBack: () => void;
toggleSidebar: () => void;
}
export const useUIStore = create<UIState>((set) => ({
export const useUIStore = create<UIState>((set, get) => ({
currentView: "feed",
sidebarCollapsed: false,
selectedPubkey: null,
selectedNote: null,
previousView: "feed",
setView: (currentView) => set({ currentView }),
openProfile: (pubkey) => set({ currentView: "profile", selectedPubkey: pubkey }),
openProfile: (pubkey) => set((s) => ({ currentView: "profile", selectedPubkey: pubkey, previousView: s.currentView as View })),
openThread: (note, from) => set({ currentView: "thread", selectedNote: note, previousView: from }),
goBack: () => set((s) => ({ currentView: s.previousView, selectedNote: null })),
toggleSidebar: () => set((s) => ({ sidebarCollapsed: !s.sidebarCollapsed })),
}));