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:
parent
cb2fd1f031
commit
b251304b4d
1 changed files with 0 additions and 24 deletions
|
|
@ -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
|
// Update season: reset pick number and unpause
|
||||||
await db
|
await db
|
||||||
.update(schema.seasons)
|
.update(schema.seasons)
|
||||||
|
|
@ -108,15 +93,6 @@ export async function action(args: any) {
|
||||||
pickNumber,
|
pickNumber,
|
||||||
teamId: rollbackSlot?.teamId,
|
teamId: rollbackSlot?.teamId,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (rollbackSlot) {
|
|
||||||
io.to(`draft-${seasonId}`).emit("timer-update", {
|
|
||||||
seasonId,
|
|
||||||
teamId: rollbackSlot.teamId,
|
|
||||||
timeRemaining: initialTime,
|
|
||||||
currentPickNumber: pickNumber,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Socket.IO error:", error);
|
console.error("Socket.IO error:", error);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue