diff --git a/WakaTime/Helpers/MonitoringManager.swift b/WakaTime/Helpers/MonitoringManager.swift index 6af8ec7..ad74380 100644 --- a/WakaTime/Helpers/MonitoringManager.swift +++ b/WakaTime/Helpers/MonitoringManager.swift @@ -102,9 +102,11 @@ class MonitoringManager { } static func set(monitoringState: MonitoringState, for bundleId: String) { - let allApps = allMonitoredApps - if !allApps.contains(bundleId) { - UserDefaults.standard.set(allApps + [bundleId], forKey: monitoringKey) + if monitoringState == .on { + UserDefaults.standard.set(Array(Set(allMonitoredApps + [bundleId])), forKey: monitoringKey) + } else { + let apps = allMonitoredApps.filter { $0 != bundleId } + UserDefaults.standard.set(apps, forKey: monitoringKey) } UserDefaults.standard.synchronize() }