From ddd4d998f4e0e6bc36c390a85331d46184de2698 Mon Sep 17 00:00:00 2001 From: codytseng Date: Wed, 12 Mar 2025 22:02:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ReplyNoteList/index.tsx | 16 +++++++++++++--- src/pages/secondary/NotePage/index.tsx | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/components/ReplyNoteList/index.tsx b/src/components/ReplyNoteList/index.tsx index be296eb3..f4e62d1b 100644 --- a/src/components/ReplyNoteList/index.tsx +++ b/src/components/ReplyNoteList/index.tsx @@ -7,6 +7,7 @@ import { isReplyNoteEvent } from '@/lib/event' import { generateEventIdFromETag } from '@/lib/tag' +import { useSecondaryPage } from '@/PageManager' import { useNostr } from '@/providers/NostrProvider' import { useNoteStats } from '@/providers/NoteStatsProvider' import client from '@/services/client.service' @@ -17,8 +18,17 @@ import ReplyNote from '../ReplyNote' const LIMIT = 100 -export default function ReplyNoteList({ event, className }: { event: NEvent; className?: string }) { +export default function ReplyNoteList({ + index, + event, + className +}: { + index?: number + event: NEvent + className?: string +}) { const { t } = useTranslation() + const { currentIndex } = useSecondaryPage() const { pubkey } = useNostr() const [rootInfo, setRootInfo] = useState<{ id: string; pubkey: string } | undefined>(undefined) const [timelineKey, setTimelineKey] = useState(undefined) @@ -75,7 +85,7 @@ export default function ReplyNoteList({ event, className }: { event: NEvent; cla }, [rootInfo]) useEffect(() => { - if (loading || !rootInfo) return + if (loading || !rootInfo || currentIndex !== index) return const init = async () => { setLoading(true) @@ -119,7 +129,7 @@ export default function ReplyNoteList({ event, className }: { event: NEvent; cla return () => { promise.then((closer) => closer?.()) } - }, [rootInfo]) + }, [rootInfo, currentIndex, index]) useEffect(() => { const replies: NEvent[] = [] diff --git a/src/pages/secondary/NotePage/index.tsx b/src/pages/secondary/NotePage/index.tsx index 1bbdc2e6..b95fa4e6 100644 --- a/src/pages/secondary/NotePage/index.tsx +++ b/src/pages/secondary/NotePage/index.tsx @@ -74,7 +74,7 @@ const NotePage = forwardRef(({ id, index }: { id?: string; index?: number }, ref {event.kind === kinds.ShortTextNote ? ( - + ) : isPictureEvent(event) ? ( ) : null}