Fix rollback to not touch timers at all

Timers are each team's time bank and should not be affected by rolling
back a pick. The previous code (both original and the first fix) was
deleting all timer rows during rollback, which was the actual root cause
of the missing timer bug.

Rollback now only does what it should: delete picks from the rollback
point onwards and reset currentPickNumber. The timer system will
naturally resume for the correct team on its next tick.

Also removes the incorrect timer-update socket emit that was sending
initialTime instead of the team's actual remaining bank.

https://claude.ai/code/session_01YPxgcQywG57KiXj7m46gLV
This commit is contained in:
Claude 2026-02-23 00:48:33 +00:00
parent cb2fd1f031
commit b251304b4d
No known key found for this signature in database

View file

@ -75,21 +75,6 @@ export async function action(args: any) {
)
);
// Clear all timers and recreate them for every team so no team is left without a timer
await db
.delete(schema.draftTimers)
.where(eq(schema.draftTimers.seasonId, seasonId));
const initialTime = season.draftInitialTime || 120;
await db.insert(schema.draftTimers).values(
draftSlots.map((slot) => ({
seasonId,
teamId: slot.teamId,
timeRemaining: initialTime,
}))
);
// Update season: reset pick number and unpause
await db
.update(schema.seasons)
@ -108,15 +93,6 @@ export async function action(args: any) {
pickNumber,
teamId: rollbackSlot?.teamId,
});
if (rollbackSlot) {
io.to(`draft-${seasonId}`).emit("timer-update", {
seasonId,
teamId: rollbackSlot.teamId,
timeRemaining: initialTime,
currentPickNumber: pickNumber,
});
}
} catch (error) {
console.error("Socket.IO error:", error);
}