Log storage issues and chain records
This commit is contained in:
18
src/main.js
18
src/main.js
@@ -157,6 +157,7 @@
|
||||
const parsed = parseInt(raw, 10);
|
||||
return Number.isFinite(parsed) ? parsed : 0;
|
||||
} catch (err) {
|
||||
console.error("Failed to load high score", { sceneId, err });
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
@@ -167,6 +168,7 @@
|
||||
const parsed = parseInt(raw, 10);
|
||||
return Number.isFinite(parsed) ? parsed : 0;
|
||||
} catch (err) {
|
||||
console.error("Failed to load longest chain", { sceneId, err });
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
@@ -175,7 +177,10 @@
|
||||
try {
|
||||
localStorage.setItem(makeStorageKey(currentScene.id), String(highScore));
|
||||
} catch (err) {
|
||||
// ignore write failures (private mode or blocked storage)
|
||||
console.error("Failed to save high score", {
|
||||
sceneId: currentScene.id,
|
||||
err,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -186,7 +191,10 @@
|
||||
String(longestChainRecord),
|
||||
);
|
||||
} catch (err) {
|
||||
// ignore write failures
|
||||
console.error("Failed to save longest chain", {
|
||||
sceneId: currentScene.id,
|
||||
err,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -651,6 +659,12 @@
|
||||
if (chainLength > longestChainRecord) {
|
||||
longestChainRecord = chainLength;
|
||||
saveLongestChain();
|
||||
console.log(
|
||||
"New longest chain record",
|
||||
chainLength,
|
||||
"scene",
|
||||
currentScene?.id,
|
||||
);
|
||||
ui.showFloatingMessage(`New chain record: ${chainLength}`, {
|
||||
durationMs: 3600,
|
||||
position: config.messages.position,
|
||||
|
||||
Reference in New Issue
Block a user