remove backend dependency from iOS demo reveal

This commit is contained in:
2026-04-10 11:17:01 +02:00
parent 7e51e5ba82
commit a4d77078a4
+36 -16
View File
@@ -329,7 +329,20 @@ struct RoundView: View {
return 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") actionMessage = localization.string(for: "errors.session_expired")
return return
} }
@@ -371,21 +384,7 @@ struct RoundView: View {
analytics.track("selection_submitted", attributes: baseSelectionAttributes(selectedOutcomeID)) analytics.track("selection_submitted", attributes: baseSelectionAttributes(selectedOutcomeID))
analytics.track("selection_accepted", 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 }) analytics.track("market_locked", attributes: baseSelectionAttributes(selectedOutcomeID).merging(["lock_reason": "swipe_selection"]) { _, new in new })
beginRevealTransition(for: round, selectedOutcomeID: selectedOutcomeID)
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 })
}
} catch { } catch {
actionMessage = hermesUserFacingErrorMessage(localization: localization, localeCode: localization.localeCode, error: error) ?? localization.string(for: "errors.generic") actionMessage = hermesUserFacingErrorMessage(localization: localization, localeCode: localization.localeCode, error: error) ?? localization.string(for: "errors.generic")
phase = .preview 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() { private func showResult() {
guard let round = repository.currentRound, let selectedOutcomeID else { guard let round = repository.currentRound, let selectedOutcomeID else {
return return
@@ -431,6 +447,10 @@ struct RoundView: View {
repository.currentSession?.deviceModel == "Demo Device" ? MockHermesData.revealMediaURL() : round.media.hlsMasterUrl 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 { private func revealStartTimeMs(for round: HermesRound) -> Int {
repository.currentSession?.deviceModel == "Demo Device" ? 0 : round.media.revealStartMs repository.currentSession?.deviceModel == "Demo Device" ? 0 : round.media.revealStartMs
} }