Accetta undo punteggio dalla regia sull'overlay iOS.
applyRemote ignorava aggiornamenti Action Cable con progressKey più basso, quindi il meno in regia non aggiornava il tabellone sullo stream. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
co-authored by
Cursor
parent
793cfaaaf1
commit
e20c2ae619
@@ -41,17 +41,18 @@ final class ScoreController: ObservableObject {
|
||||
|
||||
func applyRemote(_ remote: ScoreState, source: RemoteScoreSource = .polling) {
|
||||
if remote == score { return }
|
||||
if remote.progressKey() < score.progressKey() { return }
|
||||
if source == .polling,
|
||||
Date() < suppressRemoteUntil,
|
||||
remote.progressKey() == score.progressKey() {
|
||||
return
|
||||
}
|
||||
|
||||
if source == .cable {
|
||||
// Punteggio dalla regia: annulla sync API in volo che potrebbe sovrascrivere con stato vecchio.
|
||||
// La regia è fonte di verità: accetta anche undo (punteggio più basso).
|
||||
syncTask?.cancel()
|
||||
syncGeneration += 1
|
||||
suppressRemoteUntil = .distantPast
|
||||
publishScore(remote)
|
||||
return
|
||||
}
|
||||
|
||||
if Date() < suppressRemoteUntil, remote.progressKey() <= score.progressKey() {
|
||||
return
|
||||
}
|
||||
publishScore(remote)
|
||||
}
|
||||
@@ -177,9 +178,8 @@ final class ScoreController: ObservableObject {
|
||||
onScoreDidChange?()
|
||||
}
|
||||
|
||||
/// Applica la risposta API solo se non è più vecchia dello stato locale (evita race con la regia).
|
||||
/// Applica la risposta API dopo un'azione locale (incluso undo).
|
||||
private func applyServerScoreIfNewer(_ remote: ScoreState) {
|
||||
guard remote.progressKey() >= score.progressKey() else { return }
|
||||
publishScore(remote)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user