fixed elapsed timer on clue page cannot fix it on admin page. I am done. now to move on to the styling to match UI

This commit is contained in:
bobbert committed 2025-03-18 23:09:57 +00:00
1 parent 4cd449c0cf
commit 8fd2cabbe0
10 files changed
+226 -136

No files matched your search

+25 -2
View File
@@ -154,18 +154,41 @@ export const syncTimerWithServer = async () => {
}
const data = await response.json();
console.log("Timer sync: Server returned data:", data);
// Don't change timer if we already have it and server confirms it's active
const existingTimer = getHuntTimer();
if (existingTimer && existingTimer.startTime && data.active) {
console.log("Timer sync: Using existing timer data, confirmed by server");
return {
success: true,
data: {
startTime: existingTimer.startTime,
endTime: existingTimer.endTime || data.endTime,
active: true,
},
};
}
if (data.active && data.startTime) {
setHuntTimer(data.startTime, data.endTime);
console.log(
"Timer sync: Setting timer with startTime:",
new Date(data.startTime).toISOString()
);
// Ensure isActive is explicitly true
setHuntTimer(data.startTime, data.endTime, true);
return {
success: true,
data: {
startTime: data.startTime,
endTime: data.endTime,
active: data.active,
active: true,
},
};
} else {
console.log("Timer sync: Clearing timer as server reports inactive");
clearHuntTimer();
return { success: true, data: null };
}