remove backend dependency from iOS demo reveal
This commit is contained in:
@@ -329,7 +329,20 @@ struct RoundView: View {
|
||||
return
|
||||
}
|
||||
|
||||
guard let selectedOutcomeID, let session = repository.currentSession else {
|
||||
guard let selectedOutcomeID else {
|
||||
actionMessage = localization.string(for: "errors.session_expired")
|
||||
return
|
||||
}
|
||||
|
||||
if isDemoMode {
|
||||
analytics.track("selection_submitted", attributes: baseSelectionAttributes(selectedOutcomeID))
|
||||
analytics.track("selection_accepted", attributes: baseSelectionAttributes(selectedOutcomeID))
|
||||
analytics.track("market_locked", attributes: baseSelectionAttributes(selectedOutcomeID).merging(["lock_reason": "swipe_selection"]) { _, new in new })
|
||||
beginRevealTransition(for: round, selectedOutcomeID: selectedOutcomeID)
|
||||
return
|
||||
}
|
||||
|
||||
guard let session = repository.currentSession else {
|
||||
actionMessage = localization.string(for: "errors.session_expired")
|
||||
return
|
||||
}
|
||||
@@ -371,21 +384,7 @@ struct RoundView: View {
|
||||
analytics.track("selection_submitted", attributes: baseSelectionAttributes(selectedOutcomeID))
|
||||
analytics.track("selection_accepted", attributes: baseSelectionAttributes(selectedOutcomeID))
|
||||
analytics.track("market_locked", attributes: baseSelectionAttributes(selectedOutcomeID).merging(["lock_reason": "swipe_selection"]) { _, new in new })
|
||||
|
||||
phase = .locked
|
||||
playerCoordinator.play(rate: 2.0)
|
||||
|
||||
transitionTask?.cancel()
|
||||
transitionTask = Task { @MainActor in
|
||||
try? await Task.sleep(nanoseconds: 1_100_000_000)
|
||||
guard !Task.isCancelled else {
|
||||
return
|
||||
}
|
||||
|
||||
phase = .reveal
|
||||
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 })
|
||||
}
|
||||
beginRevealTransition(for: round, selectedOutcomeID: selectedOutcomeID)
|
||||
} catch {
|
||||
actionMessage = hermesUserFacingErrorMessage(localization: localization, localeCode: localization.localeCode, error: error) ?? localization.string(for: "errors.generic")
|
||||
phase = .preview
|
||||
@@ -395,6 +394,23 @@ struct RoundView: View {
|
||||
}
|
||||
}
|
||||
|
||||
private func beginRevealTransition(for round: HermesRound, selectedOutcomeID: String) {
|
||||
phase = .locked
|
||||
playerCoordinator.play(rate: 2.0)
|
||||
|
||||
transitionTask?.cancel()
|
||||
transitionTask = Task { @MainActor in
|
||||
try? await Task.sleep(nanoseconds: 1_100_000_000)
|
||||
guard !Task.isCancelled else {
|
||||
return
|
||||
}
|
||||
|
||||
phase = .reveal
|
||||
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 })
|
||||
}
|
||||
}
|
||||
|
||||
private func showResult() {
|
||||
guard let round = repository.currentRound, let selectedOutcomeID else {
|
||||
return
|
||||
@@ -431,6 +447,10 @@ struct RoundView: View {
|
||||
repository.currentSession?.deviceModel == "Demo Device" ? MockHermesData.revealMediaURL() : round.media.hlsMasterUrl
|
||||
}
|
||||
|
||||
private var isDemoMode: Bool {
|
||||
repository.currentSession?.deviceModel == "Demo Device"
|
||||
}
|
||||
|
||||
private func revealStartTimeMs(for round: HermesRound) -> Int {
|
||||
repository.currentSession?.deviceModel == "Demo Device" ? 0 : round.media.revealStartMs
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user