From 5783d522b7679392b9328779bba19c166acd6757 Mon Sep 17 00:00:00 2001 From: kurihada Date: Thu, 26 Feb 2026 20:10:29 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20SwipeDeck=20=E6=A3=80=E6=B5=8B=E4=BB=96?= =?UTF-8?q?=E4=BA=BA=E9=87=8D=E7=BD=AE=E5=90=8E=E8=87=AA=E5=8A=A8=E6=B8=85?= =?UTF-8?q?=E7=A9=BA=E6=9C=AC=E5=9C=B0=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 当 server 端 swipeCount 归零而本地 currentIndex > 0 时 说明其他用户执行了重置,自动调用 clearLocalState() --- src/components/SwipeDeck.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/components/SwipeDeck.tsx b/src/components/SwipeDeck.tsx index 28d1a83..139a722 100644 --- a/src/components/SwipeDeck.tsx +++ b/src/components/SwipeDeck.tsx @@ -291,6 +291,13 @@ export default function SwipeDeck({ prevLikeCounts.current = {}; }, []); + useEffect(() => { + const serverIndex = swipeCounts[userId] ?? 0; + if (serverIndex === 0 && currentIndex > 0 && !resetting) { + clearLocalState(); + } + }, [swipeCounts, userId, currentIndex, resetting, clearLocalState]); + const handleReset = useCallback(async () => { setResetting(true); try {