Fix avanzamento quarto basket e regia senza cronometro.

Normalizza il periodo nel backend quando l'app invia "Q1" via cable, così advance_period aggiorna regia e overlay; rimuove i controlli cronometro dalla regia e rende più tollerante il decode iOS al resume sessione.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Emiliano Frascaro
2026-06-20 16:15:44 +02:00
co-authored by Cursor
parent c92099a41b
commit 793cfaaaf1
18 changed files with 861 additions and 452 deletions
+28 -4
View File
@@ -235,8 +235,8 @@ struct ScoreStateDto: Decodable {
let awayPoints: Int?
let currentSet: Int?
let setPartials: [SetPartialDto]?
let timeoutHome: Bool?
let timeoutAway: Bool?
let timeoutHome: FlexibleBool?
let timeoutAway: FlexibleBool?
let period: FlexiblePeriod?
let clockSecs: Int?
let clockRunning: FlexibleBool?
@@ -256,8 +256,8 @@ struct ScoreStateDto: Decodable {
setPartials: (setPartials ?? []).map {
SetPartial(set: $0.set ?? 1, home: $0.home ?? 0, away: $0.away ?? 0)
},
timeoutHome: timeoutHome ?? false,
timeoutAway: timeoutAway ?? false,
timeoutHome: timeoutHome?.value ?? false,
timeoutAway: timeoutAway?.value ?? false,
boardType: board,
period: parsePeriodNumber(periodLabel, currentSet: currentSet),
periodLabel: periodLabel,
@@ -331,6 +331,30 @@ struct ScoreStateDataDto: Decodable {
let clockRunning: FlexibleBool?
let period: Int?
let overtime: FlexibleBool?
enum CodingKeys: String, CodingKey {
case homeScore, awayScore, clockSecs, clockRunning, period, overtime
}
init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
homeScore = Self.decodeInt(container, key: .homeScore)
awayScore = Self.decodeInt(container, key: .awayScore)
clockSecs = Self.decodeInt(container, key: .clockSecs)
clockRunning = try? container.decode(FlexibleBool.self, forKey: .clockRunning)
period = Self.decodeInt(container, key: .period)
overtime = try? container.decode(FlexibleBool.self, forKey: .overtime)
}
private static func decodeInt(
_ container: KeyedDecodingContainer<CodingKeys>,
key: CodingKeys
) -> Int? {
if let value = try? container.decode(Int.self, forKey: key) { return value }
if let text = try? container.decode(String.self, forKey: key), let value = Int(text) { return value }
if let value = try? container.decode(Double.self, forKey: key) { return Int(value) }
return nil
}
}
struct ScoreActionRequest: Encodable {
@@ -36,7 +36,8 @@ struct ScoreState: Equatable, Sendable {
"timeout_away": timeoutAway,
]
if Self.periodBoards.contains(boardType) {
payload["period"] = periodLabel ?? "\(period)"
// Il backend si aspetta un intero in sync Action Cable (non "Q1").
payload["period"] = period
payload["clock_secs"] = clockSecs
payload["clock_running"] = clockRunning
payload["home_score"] = homePoints