fix: SwipeDeck 检测他人重置后自动清空本地状态
当 server 端 swipeCount 归零而本地 currentIndex > 0 时 说明其他用户执行了重置,自动调用 clearLocalState()
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user