From d4c1a507f5a9b2ae04247be54c07f959aa58744c Mon Sep 17 00:00:00 2001 From: Alan Hamlett Date: Fri, 1 Dec 2023 00:16:14 +0100 Subject: [PATCH] Disable new apps by default --- WakaTime/Helpers/MonitoringManager.swift | 28 +----------------------- WakaTime/WakaTime.swift | 18 ++------------- 2 files changed, 3 insertions(+), 43 deletions(-) diff --git a/WakaTime/Helpers/MonitoringManager.swift b/WakaTime/Helpers/MonitoringManager.swift index b8ea271..1fb4eea 100644 --- a/WakaTime/Helpers/MonitoringManager.swift +++ b/WakaTime/Helpers/MonitoringManager.swift @@ -16,11 +16,7 @@ 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.set(false, forKey: isMonitoredKey) UserDefaults.standard.synchronize() } return true @@ -32,28 +28,6 @@ class MonitoringManager { return isAppMonitored(for: bundleId) } - static func isAppNewlySupported(for bundleId: String) -> Bool { - guard MonitoredApp.allBundleIds.contains(bundleId) else { return false } - - let isMonitoredKey = monitoredKey(bundleId: bundleId) - - return UserDefaults.standard.string(forKey: isMonitoredKey) == nil - } - - static var newlySupportedApps: [String] = { - // cache newly supported apps - var newApps: [String] = [] - for bundleId in MonitoredApp.allBundleIds { - guard - AppInfo.getIcon(bundleId: bundleId) != nil, - AppInfo.getAppName(bundleId: bundleId) != nil, - isAppNewlySupported(for: bundleId) - else { continue } - newApps.append(bundleId) - } - return newApps - }() - static func isAppElectron(for bundleId: String) -> Bool { MonitoredApp.electronAppIds.contains(bundleId) } diff --git a/WakaTime/WakaTime.swift b/WakaTime/WakaTime.swift index 01b8393..d0bbc54 100644 --- a/WakaTime/WakaTime.swift +++ b/WakaTime/WakaTime.swift @@ -29,7 +29,7 @@ class WakaTime: HeartbeatEventHandler { } configureFirebase() - checkForApiKeyOrNewApps() + checkForApiKey() watcher.heartbeatEventHandler = self watcher.statusBarDelegate = delegate @@ -57,27 +57,13 @@ class WakaTime: HeartbeatEventHandler { FirebaseApp.configure() } - private func checkForApiKeyOrNewApps() { + private func checkForApiKey() { let apiKey = ConfigFile.getSetting(section: "settings", key: "api_key") if apiKey.isEmpty { openSettingsDeeplink() - } else { - checkForNewlySupportedApps() } } - private func checkForNewlySupportedApps() { - guard PropertiesManager.hasLaunchedBefore else { return } - - let newApps = MonitoringManager.newlySupportedApps - guard !newApps.isEmpty else { return } - - openMonitoredAppsDeeplink() - - let plural = newApps.count == 1 ? "" : "s" - delegate.toastNotification("Review \(newApps.count) new app\(plural)") - } - private func openSettingsDeeplink() { guard let url = DeepLink.settings.url else { return }