fix: 500ms delay on focus reload — wait for other tab's blur save
Some checks failed
CI/CD — Build & Deploy / Build & Deploy (push) Failing after 17s

This commit is contained in:
2026-03-24 14:51:38 +01:00
parent 3145758747
commit 8cc9fdaa62

View File

@@ -95,7 +95,8 @@ export function useSaveSync({ getGameState, onLoad, playTimeSeconds }: SaveSyncO
if (!user) return undefined;
const handleFocus = () => {
apiRequest("/save").then((data) => {
// Small delay to let the other tab's blur save complete
setTimeout(() => apiRequest("/save").then((data) => {
if (data?.gameState && data.lastSave) {
if (!lastSaveRef.current || new Date(data.lastSave) > new Date(lastSaveRef.current)) {
onLoad(data.gameState);
@@ -103,7 +104,7 @@ export function useSaveSync({ getGameState, onLoad, playTimeSeconds }: SaveSyncO
console.info("[SaveSync] Reloaded from server on focus");
}
}
});
}), 500);
};
const handleBlur = () => {