Skip to content

Commit

Permalink
fix unmonitoring apps
Browse files Browse the repository at this point in the history
  • Loading branch information
alanhamlett committed Sep 14, 2024
1 parent 9af7722 commit 5e162cf
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions WakaTime/Helpers/MonitoringManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down

0 comments on commit 5e162cf

Please sign in to comment.