general: remove debug logs
This commit is contained in:
@@ -49,12 +49,9 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
private func observeSettingsChanges() {
|
private func observeSettingsChanges() {
|
||||||
settingsManager?.$settings
|
settingsManager?.$settings
|
||||||
.sink { [weak self] settings in
|
.sink { [weak self] settings in
|
||||||
print("📢 [AppDelegate] Settings changed!")
|
|
||||||
if settings.hasCompletedOnboarding && self?.hasStartedTimers == false {
|
if settings.hasCompletedOnboarding && self?.hasStartedTimers == false {
|
||||||
print("📢 [AppDelegate] Starting timers for first time")
|
|
||||||
self?.startTimers()
|
self?.startTimers()
|
||||||
} else if self?.hasStartedTimers == true {
|
} else if self?.hasStartedTimers == true {
|
||||||
print("📢 [AppDelegate] Restarting timers with new config")
|
|
||||||
// Defer timer restart to next runloop to ensure settings are fully propagated
|
// Defer timer restart to next runloop to ensure settings are fully propagated
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
self?.timerEngine?.start()
|
self?.timerEngine?.start()
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ struct GazeApp: App {
|
|||||||
// Menu bar extra (always present once onboarding is complete)
|
// Menu bar extra (always present once onboarding is complete)
|
||||||
MenuBarExtra("Gaze", systemImage: "eye.fill") {
|
MenuBarExtra("Gaze", systemImage: "eye.fill") {
|
||||||
if let timerEngine = appDelegate.timerEngine {
|
if let timerEngine = appDelegate.timerEngine {
|
||||||
let _ = print("🔵 [GazeApp] MenuBarExtra body evaluated, refreshID: \(menuBarRefreshID)")
|
|
||||||
MenuBarContentView(
|
MenuBarContentView(
|
||||||
timerEngine: timerEngine,
|
timerEngine: timerEngine,
|
||||||
settingsManager: settingsManager,
|
settingsManager: settingsManager,
|
||||||
@@ -55,7 +54,6 @@ struct GazeApp: App {
|
|||||||
.menuBarExtraStyle(.window)
|
.menuBarExtraStyle(.window)
|
||||||
.onChange(of: settingsManager.settings) { _ in
|
.onChange(of: settingsManager.settings) { _ in
|
||||||
menuBarRefreshID += 1
|
menuBarRefreshID += 1
|
||||||
print("🔵 [GazeApp] Settings changed, refreshID now: \(menuBarRefreshID)")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,17 +24,12 @@ class TimerEngine: ObservableObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func start() {
|
func start() {
|
||||||
print("🎯 [TimerEngine] start() called, subscription exists: \(timerSubscription != nil)")
|
|
||||||
|
|
||||||
// If timers are already running, just update configurations without resetting
|
// If timers are already running, just update configurations without resetting
|
||||||
if timerSubscription != nil {
|
if timerSubscription != nil {
|
||||||
print("🎯 [TimerEngine] Updating existing configurations")
|
|
||||||
updateConfigurations()
|
updateConfigurations()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
print("🎯 [TimerEngine] Initial start - creating all timer states")
|
|
||||||
|
|
||||||
// Initial start - create all timer states
|
// Initial start - create all timer states
|
||||||
stop()
|
stop()
|
||||||
|
|
||||||
@@ -49,13 +44,11 @@ class TimerEngine: ObservableObject {
|
|||||||
isPaused: false,
|
isPaused: false,
|
||||||
isActive: true
|
isActive: true
|
||||||
)
|
)
|
||||||
print("🎯 [TimerEngine] Created state for \(timerType.displayName): \(config.intervalSeconds)s")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assign the entire dictionary at once to trigger @Published
|
// Assign the entire dictionary at once to trigger @Published
|
||||||
timerStates = newStates
|
timerStates = newStates
|
||||||
print("🎯 [TimerEngine] Assigned \(newStates.count) timer states")
|
|
||||||
|
|
||||||
// Start user timers
|
// Start user timers
|
||||||
for userTimer in settingsManager.settings.userTimers {
|
for userTimer in settingsManager.settings.userTimers {
|
||||||
@@ -72,21 +65,16 @@ class TimerEngine: ObservableObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func updateConfigurations() {
|
private func updateConfigurations() {
|
||||||
print("🔄 [TimerEngine] updateConfigurations() called")
|
|
||||||
print("🔄 [TimerEngine] Current timerStates keys: \(timerStates.keys.map { $0.displayName })")
|
|
||||||
var newStates: [TimerType: TimerState] = [:]
|
var newStates: [TimerType: TimerState] = [:]
|
||||||
|
|
||||||
for timerType in TimerType.allCases {
|
for timerType in TimerType.allCases {
|
||||||
let config = settingsManager.timerConfiguration(for: timerType)
|
let config = settingsManager.timerConfiguration(for: timerType)
|
||||||
print("🔄 [TimerEngine] Processing \(timerType.displayName): enabled=\(config.enabled), intervalSeconds=\(config.intervalSeconds)")
|
|
||||||
|
|
||||||
if config.enabled {
|
if config.enabled {
|
||||||
if let existingState = timerStates[timerType] {
|
if let existingState = timerStates[timerType] {
|
||||||
// Timer exists - check if interval changed
|
// Timer exists - check if interval changed
|
||||||
print("🔄 [TimerEngine] \(timerType.displayName) exists in current states")
|
|
||||||
if existingState.originalIntervalSeconds != config.intervalSeconds {
|
if existingState.originalIntervalSeconds != config.intervalSeconds {
|
||||||
// Interval changed - reset with new interval
|
// Interval changed - reset with new interval
|
||||||
print("🔄 [TimerEngine] \(timerType.displayName) interval changed: \(existingState.originalIntervalSeconds)s -> \(config.intervalSeconds)s, resetting")
|
|
||||||
newStates[timerType] = TimerState(
|
newStates[timerType] = TimerState(
|
||||||
type: timerType,
|
type: timerType,
|
||||||
intervalSeconds: config.intervalSeconds,
|
intervalSeconds: config.intervalSeconds,
|
||||||
@@ -95,12 +83,10 @@ class TimerEngine: ObservableObject {
|
|||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
// Interval unchanged - keep existing state
|
// Interval unchanged - keep existing state
|
||||||
print("🔄 [TimerEngine] \(timerType.displayName) unchanged, keeping state (remaining: \(existingState.remainingSeconds)s)")
|
|
||||||
newStates[timerType] = existingState
|
newStates[timerType] = existingState
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Timer was just enabled - create new state
|
// Timer was just enabled - create new state
|
||||||
print("🔄 [TimerEngine] \(timerType.displayName) NOT in current states, newly enabled, creating state")
|
|
||||||
newStates[timerType] = TimerState(
|
newStates[timerType] = TimerState(
|
||||||
type: timerType,
|
type: timerType,
|
||||||
intervalSeconds: config.intervalSeconds,
|
intervalSeconds: config.intervalSeconds,
|
||||||
@@ -108,18 +94,10 @@ class TimerEngine: ObservableObject {
|
|||||||
isActive: true
|
isActive: true
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if timerStates[timerType] != nil {
|
|
||||||
print("🔄 [TimerEngine] \(timerType.displayName) disabled, removing state")
|
|
||||||
} else {
|
|
||||||
print("🔄 [TimerEngine] \(timerType.displayName) disabled and not in current states")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// If config.enabled is false and timer exists, it will be removed
|
// If config.enabled is false and timer exists, it will be removed
|
||||||
}
|
}
|
||||||
|
|
||||||
print("🔄 [TimerEngine] New states keys: \(newStates.keys.map { $0.displayName })")
|
|
||||||
print("🔄 [TimerEngine] Assigning \(newStates.count) timer states (was \(timerStates.count))")
|
|
||||||
// Assign the entire dictionary at once to trigger @Published
|
// Assign the entire dictionary at once to trigger @Published
|
||||||
timerStates = newStates
|
timerStates = newStates
|
||||||
|
|
||||||
|
|||||||
@@ -120,8 +120,6 @@ struct SettingsWindowView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func applySettings() {
|
private func applySettings() {
|
||||||
print("🔧 [SettingsWindow] Applying settings...")
|
|
||||||
|
|
||||||
// Create a new AppSettings object with updated values
|
// Create a new AppSettings object with updated values
|
||||||
// This triggers the didSet observer in SettingsManager
|
// This triggers the didSet observer in SettingsManager
|
||||||
let updatedSettings = AppSettings(
|
let updatedSettings = AppSettings(
|
||||||
@@ -145,14 +143,9 @@ struct SettingsWindowView: View {
|
|||||||
playSounds: settingsManager.settings.playSounds
|
playSounds: settingsManager.settings.playSounds
|
||||||
)
|
)
|
||||||
|
|
||||||
print("🔧 [SettingsWindow] Old settings - Blink: \(settingsManager.settings.blinkTimer.enabled), interval: \(settingsManager.settings.blinkTimer.intervalSeconds)")
|
|
||||||
print("🔧 [SettingsWindow] New settings - Blink: \(updatedSettings.blinkTimer.enabled), interval: \(updatedSettings.blinkTimer.intervalSeconds)")
|
|
||||||
|
|
||||||
// Assign the entire settings object to trigger didSet and observers
|
// Assign the entire settings object to trigger didSet and observers
|
||||||
settingsManager.settings = updatedSettings
|
settingsManager.settings = updatedSettings
|
||||||
|
|
||||||
print("🔧 [SettingsWindow] Settings assigned to manager")
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if launchAtLogin {
|
if launchAtLogin {
|
||||||
try LaunchAtLoginManager.enable()
|
try LaunchAtLoginManager.enable()
|
||||||
|
|||||||
Reference in New Issue
Block a user