fix iOS demo round timing
This commit is contained in:
@@ -38,7 +38,8 @@ struct RoundView: View {
|
||||
TimelineView(.periodic(from: Date(), by: 1)) { _ in
|
||||
let round = repository.currentRound
|
||||
let now = repository.serverNow()
|
||||
let remaining = max(lockAt.timeIntervalSince(now), 0)
|
||||
let activeLockAt = round?.event.lockAt ?? lockAt
|
||||
let remaining = max(activeLockAt.timeIntervalSince(now), 0)
|
||||
let timerLocked = round != nil && remaining <= 0
|
||||
let bannerMessage = actionMessage ?? hermesUserFacingErrorMessage(
|
||||
localization: localization,
|
||||
@@ -118,7 +119,7 @@ struct RoundView: View {
|
||||
|
||||
Spacer(minLength: 12)
|
||||
|
||||
SemiCircleCountdownView(progress: progressValue(for: remaining), label: Self.countdownText(for: remaining))
|
||||
SemiCircleCountdownView(progress: progressValue(for: remaining, round: round), label: Self.countdownText(for: remaining))
|
||||
}
|
||||
.padding(.horizontal, HermesTheme.screenPadding)
|
||||
.padding(.top, 112)
|
||||
@@ -382,7 +383,7 @@ struct RoundView: View {
|
||||
}
|
||||
|
||||
phase = .reveal
|
||||
playerCoordinator.play(url: revealMediaURL(for: round), startTimeMs: round.media.revealStartMs, rate: 1.0)
|
||||
playerCoordinator.play(url: revealMediaURL(for: round), startTimeMs: revealStartTimeMs(for: round), rate: 1.0)
|
||||
analytics.track("reveal_started", attributes: roundAnalyticsAttributes(round).merging(baseSelectionAttributes(selectedOutcomeID)) { _, new in new })
|
||||
}
|
||||
} catch {
|
||||
@@ -430,6 +431,10 @@ struct RoundView: View {
|
||||
repository.currentSession?.deviceModel == "Demo Device" ? MockHermesData.revealMediaURL() : round.media.hlsMasterUrl
|
||||
}
|
||||
|
||||
private func revealStartTimeMs(for round: HermesRound) -> Int {
|
||||
repository.currentSession?.deviceModel == "Demo Device" ? 0 : round.media.revealStartMs
|
||||
}
|
||||
|
||||
private func promptTitle(for round: HermesRound?) -> String {
|
||||
guard let round else {
|
||||
return localization.string(for: "common.loading")
|
||||
@@ -488,8 +493,9 @@ struct RoundView: View {
|
||||
return outcomeTitle(outcome)
|
||||
}
|
||||
|
||||
private func progressValue(for remaining: TimeInterval) -> Double {
|
||||
min(max(remaining / 15.0, 0), 1)
|
||||
private func progressValue(for remaining: TimeInterval, round: HermesRound?) -> Double {
|
||||
let totalDuration = round.map { Double(max($0.media.previewEndMs - $0.media.previewStartMs, 1)) / 1_000.0 } ?? 15.0
|
||||
return min(max(remaining / totalDuration, 0), 1)
|
||||
}
|
||||
|
||||
private static func countdownText(for remaining: TimeInterval) -> String {
|
||||
|
||||
Reference in New Issue
Block a user