generated from nhcarrigan/template
feat: show save errors in the UI instead of console
Add syncError state to GameContext. forceSync now catches errors
and displays them in the ResourceBar for 5 seconds, replacing the
cloud save timestamp with '❌ Save failed'. Signature mismatches
are also cleared from localStorage so the next save can proceed.
Auto-save silently self-heals bad signatures without surfacing an error.
This commit is contained in:
@@ -33,7 +33,7 @@ export const ResourceBar = ({
|
||||
isSyncing,
|
||||
onForceSync,
|
||||
}: ResourceBarProps): React.JSX.Element => {
|
||||
const { formatNumber } = useGame();
|
||||
const { formatNumber, syncError } = useGame();
|
||||
const anyFull = Object.values(resources).some((v) => v >= RESOURCE_CAP);
|
||||
return (
|
||||
<>
|
||||
@@ -68,11 +68,15 @@ export const ResourceBar = ({
|
||||
</div>
|
||||
)}
|
||||
<div className="profile-buttons">
|
||||
{lastSavedAt !== null && (
|
||||
{syncError !== null ? (
|
||||
<span className="save-status save-error" title={syncError}>
|
||||
❌ Save failed
|
||||
</span>
|
||||
) : lastSavedAt !== null ? (
|
||||
<span className="save-status" title={new Date(lastSavedAt).toLocaleString()}>
|
||||
☁️ {formatRelativeTime(lastSavedAt)}
|
||||
</span>
|
||||
)}
|
||||
) : null}
|
||||
<button
|
||||
className="force-save-button"
|
||||
disabled={isSyncing}
|
||||
|
||||
Reference in New Issue
Block a user