Skip to content

Commit

Permalink
Merge pull request #187 from wakatime/main
Browse files Browse the repository at this point in the history
Release v4.0.1
  • Loading branch information
alanhamlett authored Nov 30, 2023
2 parents 98b9986 + 8f08f5b commit 9a03748
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions WakaTime/Helpers/MonitoringManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ class MonitoringManager {
let isMonitored = UserDefaults.standard.bool(forKey: isMonitoredKey)
return isMonitored
} else {

// make sure newly supported apps are cached before we set defaults
assert(newlySupportedApps.count > -1)

UserDefaults.standard.set(true, forKey: isMonitoredKey)
UserDefaults.standard.synchronize()
}
Expand All @@ -36,7 +40,8 @@ class MonitoringManager {
return UserDefaults.standard.string(forKey: isMonitoredKey) == nil
}

static func newlySupportedApps() -> [String] {
static var newlySupportedApps: [String] = {
// cache newly supported apps
var newApps: [String] = []
for bundleId in MonitoredApp.allBundleIds {
guard
Expand All @@ -47,7 +52,7 @@ class MonitoringManager {
newApps.append(bundleId)
}
return newApps
}
}()

static func isAppElectron(for bundleId: String) -> Bool {
MonitoredApp.electronAppIds.contains(bundleId)
Expand Down
2 changes: 1 addition & 1 deletion WakaTime/WakaTime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class WakaTime: HeartbeatEventHandler {
private func checkForNewlySupportedApps() {
guard PropertiesManager.hasLaunchedBefore else { return }

let newApps = MonitoringManager.newlySupportedApps()
let newApps = MonitoringManager.newlySupportedApps
guard !newApps.isEmpty else { return }

openMonitoredAppsDeeplink()
Expand Down

0 comments on commit 9a03748

Please sign in to comment.