fix: 🐛

This commit is contained in:
codytseng 2026-01-04 23:02:20 +08:00
parent 9f6045461c
commit 36959a1052
2 changed files with 6 additions and 2 deletions

View file

@ -93,6 +93,8 @@ const NoteList = forwardRef<
const [refreshCount, setRefreshCount] = useState(0) const [refreshCount, setRefreshCount] = useState(0)
const supportTouch = useMemo(() => isTouchDevice(), []) const supportTouch = useMemo(() => isTouchDevice(), [])
const topRef = useRef<HTMLDivElement | null>(null) const topRef = useRef<HTMLDivElement | null>(null)
const showNewNotesDirectlyRef = useRef(showNewNotesDirectly)
showNewNotesDirectlyRef.current = showNewNotesDirectly
const shouldHideEvent = useCallback( const shouldHideEvent = useCallback(
(evt: Event) => { (evt: Event) => {
@ -331,7 +333,7 @@ const NoteList = forwardRef<
} }
}, },
onNew: (event) => { onNew: (event) => {
if (showNewNotesDirectly) { if (showNewNotesDirectlyRef.current) {
setEvents((oldEvents) => setEvents((oldEvents) =>
oldEvents.some((e) => e.id === event.id) ? oldEvents : [event, ...oldEvents] oldEvents.some((e) => e.id === event.id) ? oldEvents : [event, ...oldEvents]
) )

View file

@ -97,6 +97,8 @@ const UserAggregationList = forwardRef<
const bottomRef = useRef<HTMLDivElement | null>(null) const bottomRef = useRef<HTMLDivElement | null>(null)
const topRef = useRef<HTMLDivElement | null>(null) const topRef = useRef<HTMLDivElement | null>(null)
const nonPinnedTopRef = useRef<HTMLDivElement | null>(null) const nonPinnedTopRef = useRef<HTMLDivElement | null>(null)
const showNewNotesDirectlyRef = useRef(showNewNotesDirectly)
showNewNotesDirectlyRef.current = showNewNotesDirectly
const scrollToTop = (behavior: ScrollBehavior = 'instant') => { const scrollToTop = (behavior: ScrollBehavior = 'instant') => {
setTimeout(() => { setTimeout(() => {
@ -178,7 +180,7 @@ const UserAggregationList = forwardRef<
} }
}, },
onNew: (event) => { onNew: (event) => {
if (showNewNotesDirectly) { if (showNewNotesDirectlyRef.current) {
setEvents((oldEvents) => [event, ...oldEvents]) setEvents((oldEvents) => [event, ...oldEvents])
} else { } else {
setNewEvents((oldEvents) => setNewEvents((oldEvents) =>