fix: SwipeDeck 检测他人重置后自动清空本地状态

当 server 端 swipeCount 归零而本地 currentIndex > 0 时
说明其他用户执行了重置,自动调用 clearLocalState()
This commit is contained in:
2026-02-26 20:10:29 +08:00
parent b9a07f84c0
commit 5783d522b7
+7
View File
@@ -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 {