Skip to content

Commit

Permalink
Use last install date instead of last refresh date
Browse files Browse the repository at this point in the history
  • Loading branch information
jaceklyp committed Dec 21, 2023
1 parent 21afb81 commit 9692c81
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
2 changes: 2 additions & 0 deletions DuckDuckGo/Common/Utilities/UserDefaultsWrapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public struct UserDefaultsWrapper<T> {
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"
Expand Down
4 changes: 4 additions & 0 deletions DuckDuckGo/Configuration/ConfigurationManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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),
Expand Down
10 changes: 8 additions & 2 deletions DuckDuckGo/Menus/MainMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
}

Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/Menus/MainMenuActions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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?) {
Expand Down

0 comments on commit 9692c81

Please sign in to comment.