Add votes-final flag, warn on missing votes, and sync phases with results toggle
This commit is contained in:
@@ -23,13 +23,26 @@ internal static class EndpointHelpers
|
||||
var player = await db.Players.FirstOrDefaultAsync(p => p.Id == playerId);
|
||||
if (player is null) return Phase.Suggest;
|
||||
|
||||
var state = await db.AppState.FirstAsync();
|
||||
|
||||
// Auto-upgrade any legacy Reveal phase to Vote to avoid blank screens
|
||||
if (player.CurrentPhase == Phase.Reveal)
|
||||
{
|
||||
player.CurrentPhase = Phase.Vote;
|
||||
await db.SaveChangesAsync();
|
||||
}
|
||||
|
||||
// Keep phases aligned with results availability
|
||||
if (state.ResultsOpen && player.CurrentPhase != Phase.Results)
|
||||
{
|
||||
player.CurrentPhase = Phase.Results;
|
||||
}
|
||||
else if (!state.ResultsOpen && player.CurrentPhase == Phase.Results)
|
||||
{
|
||||
player.CurrentPhase = Phase.Vote;
|
||||
player.VotesFinal = false;
|
||||
}
|
||||
|
||||
await db.SaveChangesAsync();
|
||||
return player.CurrentPhase;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user