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) =>