mirror of
https://github.com/hoornet/vega.git
synced 2026-05-07 20:59:12 -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:
@@ -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<FeedTab>("global");
|
||||
const { feedTab: tab, setFeedTab: setTab } = useUIStore();
|
||||
const [followNotes, setFollowNotes] = useState<NDKEvent[]>([]);
|
||||
const [followLoading, setFollowLoading] = useState(false);
|
||||
|
||||
|
||||
@@ -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"
|
||||
>
|
||||
|
||||
@@ -173,7 +173,7 @@ function tryOpenNostrEntity(raw: string): boolean {
|
||||
|
||||
function QuotePreview({ eventId }: { eventId: string }) {
|
||||
const [event, setEvent] = useState<NDKEvent | null>(null);
|
||||
const { openThread } = useUIStore();
|
||||
const { openThread, currentView } = useUIStore();
|
||||
const profile = useProfile(event?.pubkey ?? "");
|
||||
|
||||
useEffect(() => {
|
||||
@@ -189,7 +189,7 @@ function QuotePreview({ eventId }: { eventId: string }) {
|
||||
return (
|
||||
<div
|
||||
className="mt-2 border border-border bg-bg-raised px-3 py-2 cursor-pointer hover:bg-bg-hover transition-colors"
|
||||
onClick={(e) => { e.stopPropagation(); openThread(event, "feed"); }}
|
||||
onClick={(e) => { e.stopPropagation(); openThread(event, currentView as "feed" | "profile"); }}
|
||||
>
|
||||
<div className="flex items-center gap-2 mb-1">
|
||||
{profile?.picture && (
|
||||
|
||||
Reference in New Issue
Block a user