From 3055a7cbf1bb2b90636d7964d5be87fedc07d09f Mon Sep 17 00:00:00 2001 From: Tunglies <77394545+Tunglies@users.noreply.github.com> Date: Sun, 29 Nov 2026 17:16:53 +0800 Subject: [PATCH] perf(logs): index descending virtual rows without reversing the list --- src/pages/logs.tsx | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/pages/logs.tsx b/src/pages/logs.tsx index ad3231362..e9d807e24 100644 --- a/src/pages/logs.tsx +++ b/src/pages/logs.tsx @@ -52,21 +52,16 @@ const LogPage = () => { }) }, [logData, logState, match, searchState.text]) - const filteredLogs = useMemo( - () => (isDescending ? [...filterLogs].reverse() : filterLogs), - [filterLogs, isDescending], - ) - const scrollRef = useRef({ isNearBottom: true }) const virtuosoRef = useRef(null) useEffect(() => { if (!isDescending && scrollRef.current.isNearBottom) { - virtuosoRef.current?.scrollToIndex(filteredLogs.length - 1, { + virtuosoRef.current?.scrollToIndex(filterLogs.length - 1, { behavior: 'smooth', }) } - }, [isDescending, filteredLogs.length]) + }, [isDescending, filterLogs.length]) const handleLogLevelChange = (newLevel: LogFilter) => { setClashLog((pre) => ({ ...pre!, logFilter: newLevel })) @@ -176,13 +171,16 @@ const LogPage = () => { /> - {filteredLogs.length > 0 ? ( + {filterLogs.length > 0 ? ( ( - + )} onScroll={(event) => { const element = event.currentTarget as HTMLDivElement