remove backend dependency from iOS demo reveal

This commit is contained in:
2026-04-10 11:17:01 +02:00
parent 7e51e5ba82
commit a4d77078a4
+28 -8
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,7 +384,17 @@ 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)
} catch {
actionMessage = hermesUserFacingErrorMessage(localization: localization, localeCode: localization.localeCode, error: error) ?? localization.string(for: "errors.generic")
phase = .preview
}
isSubmitting = false
}
}
private func beginRevealTransition(for round: HermesRound, selectedOutcomeID: String) {
phase = .locked phase = .locked
playerCoordinator.play(rate: 2.0) playerCoordinator.play(rate: 2.0)
@@ -386,13 +409,6 @@ struct RoundView: View {
playerCoordinator.play(url: revealMediaURL(for: round), startTimeMs: revealStartTimeMs(for: round), 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 }) analytics.track("reveal_started", attributes: roundAnalyticsAttributes(round).merging(baseSelectionAttributes(selectedOutcomeID)) { _, new in new })
} }
} catch {
actionMessage = hermesUserFacingErrorMessage(localization: localization, localeCode: localization.localeCode, error: error) ?? localization.string(for: "errors.generic")
phase = .preview
}
isSubmitting = false
}
} }
private func showResult() { private func showResult() {
@@ -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
} }