From 36959a1052af27cc98f688b0d815db99c3bdac56 Mon Sep 17 00:00:00 2001 From: codytseng Date: Sun, 4 Jan 2026 23:02:20 +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/NoteList/index.tsx | 4 +++- src/components/UserAggregationList/index.tsx | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/NoteList/index.tsx b/src/components/NoteList/index.tsx index 850ee99..653596c 100644 --- a/src/components/NoteList/index.tsx +++ b/src/components/NoteList/index.tsx @@ -93,6 +93,8 @@ const NoteList = forwardRef< const [refreshCount, setRefreshCount] = useState(0) const supportTouch = useMemo(() => isTouchDevice(), []) const topRef = useRef(null) + const showNewNotesDirectlyRef = useRef(showNewNotesDirectly) + showNewNotesDirectlyRef.current = showNewNotesDirectly const shouldHideEvent = useCallback( (evt: Event) => { @@ -331,7 +333,7 @@ const NoteList = forwardRef< } }, onNew: (event) => { - if (showNewNotesDirectly) { + if (showNewNotesDirectlyRef.current) { setEvents((oldEvents) => oldEvents.some((e) => e.id === event.id) ? oldEvents : [event, ...oldEvents] ) diff --git a/src/components/UserAggregationList/index.tsx b/src/components/UserAggregationList/index.tsx index 5f2d839..ecc4987 100644 --- a/src/components/UserAggregationList/index.tsx +++ b/src/components/UserAggregationList/index.tsx @@ -97,6 +97,8 @@ const UserAggregationList = forwardRef< const bottomRef = useRef(null) const topRef = useRef(null) const nonPinnedTopRef = useRef(null) + const showNewNotesDirectlyRef = useRef(showNewNotesDirectly) + showNewNotesDirectlyRef.current = showNewNotesDirectly const scrollToTop = (behavior: ScrollBehavior = 'instant') => { setTimeout(() => { @@ -178,7 +180,7 @@ const UserAggregationList = forwardRef< } }, onNew: (event) => { - if (showNewNotesDirectly) { + if (showNewNotesDirectlyRef.current) { setEvents((oldEvents) => [event, ...oldEvents]) } else { setNewEvents((oldEvents) =>