From e7a918443fc321c3cb662d719317efee00227acc Mon Sep 17 00:00:00 2001 From: Michael Freno Date: Sun, 18 Jan 2026 00:31:41 -0500 Subject: [PATCH] fix: oops --- Gaze/Models/TimerConfiguration.swift | 36 +++++++++------------------- Gaze/Services/TimerEngine.swift | 28 +++++++++++----------- 2 files changed, 25 insertions(+), 39 deletions(-) diff --git a/Gaze/Models/TimerConfiguration.swift b/Gaze/Models/TimerConfiguration.swift index 977918b..dbc547b 100644 --- a/Gaze/Models/TimerConfiguration.swift +++ b/Gaze/Models/TimerConfiguration.swift @@ -7,31 +7,17 @@ import Foundation -/// Unified configuration for all timer types (built-in and user) -protocol TimerConfigurationProtocol: Codable, Equatable { - var intervalSeconds: Int { get } - var enabled: Bool { get } - var id: String { get } -} - -/// Configuration for a built-in timer -struct BuiltInTimerConfiguration: TimerConfigurationProtocol { - let intervalSeconds: Int - let enabled: Bool - let timerType: TimerType +struct TimerConfiguration: Codable, Equatable, Hashable, Sendable { + var enabled: Bool + var intervalSeconds: Int - var id: String { - return "builtIn:\(timerType.rawValue)" - } -} - -/// Configuration for a user timer -struct UserTimerConfiguration: TimerConfigurationProtocol { - let intervalSeconds: Int - let enabled: Bool - let userTimer: UserTimer - - var id: String { - return "user:\(userTimer.id)" + init(enabled: Bool = true, intervalSeconds: Int) { + self.enabled = enabled + self.intervalSeconds = intervalSeconds + } + + var intervalMinutes: Int { + get { intervalSeconds / 60 } + set { intervalSeconds = newValue * 60 } } } diff --git a/Gaze/Services/TimerEngine.swift b/Gaze/Services/TimerEngine.swift index dd9c134..a0d18bd 100644 --- a/Gaze/Services/TimerEngine.swift +++ b/Gaze/Services/TimerEngine.swift @@ -287,10 +287,10 @@ class TimerEngine: ObservableObject { timerStates[identifier] = state } - func skipNext(identifier: TimerIdentifier) { +func skipNext(identifier: TimerIdentifier) { guard let state = timerStates[identifier] else { return } - // Unified approach to get interval - no more special handling needed + // Unified approach to get interval - no more separate handling for user timers let intervalSeconds = getTimerInterval(for: identifier) timerStates[identifier] = TimerState( @@ -300,18 +300,7 @@ class TimerEngine: ObservableObject { isActive: state.isActive ) } - - func dismissReminder() { - guard let reminder = activeReminder else { return } - activeReminder = nil - - let identifier = reminder.identifier - skipNext(identifier: identifier) - resumeTimer(identifier: identifier) - - enforceModeService?.handleReminderDismissed() - } - + /// Unified way to get interval for any timer type private func getTimerInterval(for identifier: TimerIdentifier) -> Int { switch identifier { @@ -326,6 +315,17 @@ class TimerEngine: ObservableObject { } } + func dismissReminder() { + guard let reminder = activeReminder else { return } + activeReminder = nil + + let identifier = reminder.identifier + skipNext(identifier: identifier) + resumeTimer(identifier: identifier) + + enforceModeService?.handleReminderDismissed() + } + private func handleTick() { for (identifier, state) in timerStates { guard !state.isPaused else { continue }