From 9692c8169576de6764ae0bbfaa75475a9b319906 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacek=20=C5=81yp?= Date: Thu, 21 Dec 2023 17:12:51 +0100 Subject: [PATCH] Use last install date instead of last refresh date --- DuckDuckGo/Common/Utilities/UserDefaultsWrapper.swift | 2 ++ DuckDuckGo/Configuration/ConfigurationManager.swift | 4 ++++ DuckDuckGo/Menus/MainMenu.swift | 10 ++++++++-- DuckDuckGo/Menus/MainMenuActions.swift | 2 +- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/DuckDuckGo/Common/Utilities/UserDefaultsWrapper.swift b/DuckDuckGo/Common/Utilities/UserDefaultsWrapper.swift index 0382b5de65..7c8f0b7ce8 100644 --- a/DuckDuckGo/Common/Utilities/UserDefaultsWrapper.swift +++ b/DuckDuckGo/Common/Utilities/UserDefaultsWrapper.swift @@ -41,6 +41,8 @@ public struct UserDefaultsWrapper { case configStoragePrivacyConfigurationEtag = "config.storage.privacyconfiguration.etag" case configFBConfigEtag = "config.storage.fbconfig.etag" + case configLastInstalled = "config.last.installed" + case fireproofDomains = "com.duckduckgo.fireproofing.allowedDomains" case areDomainsMigratedToETLDPlus1 = "com.duckduckgo.are-domains-migrated-to-etldplus1" case unprotectedDomains = "com.duckduckgo.contentblocker.unprotectedDomains" diff --git a/DuckDuckGo/Configuration/ConfigurationManager.swift b/DuckDuckGo/Configuration/ConfigurationManager.swift index ffd4caf936..a64673dfc0 100644 --- a/DuckDuckGo/Configuration/ConfigurationManager.swift +++ b/DuckDuckGo/Configuration/ConfigurationManager.swift @@ -61,6 +61,9 @@ final class ConfigurationManager { @UserDefaultsWrapper(key: .configLastUpdated, defaultValue: .distantPast) private(set) var lastUpdateTime: Date + @UserDefaultsWrapper(key: .configLastInstalled, defaultValue: nil) + private(set) var lastConfigurationInstallDate: Date? + private var timerCancellable: AnyCancellable? private var lastRefreshCheckTime: Date = Date() @@ -200,6 +203,7 @@ final class ConfigurationManager { } private func updateTrackerBlockingDependencies() { + lastConfigurationInstallDate = Date() ContentBlocking.shared.trackerDataManager.reload(etag: ConfigurationStore.shared.loadEtag(for: .trackerDataSet), data: ConfigurationStore.shared.loadData(for: .trackerDataSet)) ContentBlocking.shared.privacyConfigurationManager.reload(etag: ConfigurationStore.shared.loadEtag(for: .privacyConfiguration), diff --git a/DuckDuckGo/Menus/MainMenu.swift b/DuckDuckGo/Menus/MainMenu.swift index 7c9f7c3505..f0f739b840 100644 --- a/DuckDuckGo/Menus/MainMenu.swift +++ b/DuckDuckGo/Menus/MainMenu.swift @@ -635,8 +635,14 @@ import Subscription } private func updateRemoteConfigurationInfo() { - let dateString = DateFormatter.localizedString(from: ConfigurationManager.shared.lastUpdateTime, dateStyle: .short, timeStyle: .medium) - configurationDateAndTimeMenuItem.title = "Last Update Time: \(dateString)" + var dateString: String + if let date = ConfigurationManager.shared.lastConfigurationInstallDate { + dateString = DateFormatter.localizedString(from: date, dateStyle: .short, timeStyle: .medium) + configurationDateAndTimeMenuItem.title = "Last Update Time: \(dateString)" + } else { + dateString = "Last Update Time: -" + } + configurationDateAndTimeMenuItem.title = dateString customConfigurationUrlMenuItem.title = "Configuration URL: \(AppConfigurationURLProvider().url(for: .privacyConfiguration).absoluteString)" } diff --git a/DuckDuckGo/Menus/MainMenuActions.swift b/DuckDuckGo/Menus/MainMenuActions.swift index da0bc32518..895f31c525 100644 --- a/DuckDuckGo/Menus/MainMenuActions.swift +++ b/DuckDuckGo/Menus/MainMenuActions.swift @@ -733,7 +733,7 @@ extension MainViewController { @objc func reloadConfigurationNow(_ sender: Any?) { OSLog.loggingCategories.insert(OSLog.AppCategories.config.rawValue) - ConfigurationManager.shared.forceRefresh() + ConfigurationManager.shared.forceRefresh(isDebug: true) } private func setConfigurationUrl(_ configurationUrl: URL?) {