diff --git a/DuckDuckGo.xcodeproj/project.pbxproj b/DuckDuckGo.xcodeproj/project.pbxproj index 3f22489b51..e907bfb443 100644 --- a/DuckDuckGo.xcodeproj/project.pbxproj +++ b/DuckDuckGo.xcodeproj/project.pbxproj @@ -10287,7 +10287,7 @@ repositoryURL = "https://github.com/duckduckgo/BrowserServicesKit"; requirement = { kind = exactVersion; - version = 75.0.3; + version = 75.0.4; }; }; AA06B6B52672AF8100F541C5 /* XCRemoteSwiftPackageReference "Sparkle" */ = { diff --git a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 44491f03c9..a28adefe84 100644 --- a/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/DuckDuckGo.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -14,8 +14,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/duckduckgo/BrowserServicesKit", "state" : { - "revision" : "9bf7b16196ac4a78bf9189841d9823047b5c141b", - "version" : "75.0.3" + "revision" : "02e87697d9e8d897bde0a913b7ed5b0943cbe993", + "version" : "75.0.4" } }, { diff --git a/DuckDuckGo/AppDelegate/AppDelegate.swift b/DuckDuckGo/AppDelegate/AppDelegate.swift index 83db2e1b8f..c71f1f5915 100644 --- a/DuckDuckGo/AppDelegate/AppDelegate.swift +++ b/DuckDuckGo/AppDelegate/AppDelegate.swift @@ -284,15 +284,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, FileDownloadManagerDel let syncDataProviders = SyncDataProviders(bookmarksDatabase: BookmarkDatabase.shared.db) let syncService = DDGSync(dataProvidersSource: syncDataProviders, errorEvents: SyncErrorHandler(), log: OSLog.sync) syncService.initializeIfNeeded(isInternalUser: internalUserDecider?.isInternalUser ?? false) - - syncStateCancellable = syncService.authStatePublisher - .prepend(syncService.authState) - .map { $0 == .inactive } - .removeDuplicates() - .sink { isSyncDisabled in - LocalBookmarkManager.shared.updateBookmarkDatabaseCleanupSchedule(shouldEnable: isSyncDisabled) - syncDataProviders.credentialsAdapter.updateDatabaseCleanupSchedule(shouldEnable: isSyncDisabled) - } + syncDataProviders.setUpDatabaseCleaners(syncService: syncService) // This is also called in applicationDidBecomeActive, but we're also calling it here, since // syncService can be nil when applicationDidBecomeActive is called during startup, if a modal @@ -303,14 +295,6 @@ final class AppDelegate: NSObject, NSApplicationDelegate, FileDownloadManagerDel self.syncDataProviders = syncDataProviders self.syncService = syncService - - bookmarksManager.bookmarkDatabaseCleaner.isSyncActive = { [weak self] in - self?.syncService?.authState == .active - } - - syncDataProviders.credentialsAdapter.databaseCleaner.isSyncActive = { [weak self] in - self?.syncService?.authState == .active - } } private func subscribeToEmailProtectionStatusNotifications() { diff --git a/DuckDuckGo/Bookmarks/Model/BookmarkManager.swift b/DuckDuckGo/Bookmarks/Model/BookmarkManager.swift index 2238b33a0f..a1695b2ee6 100644 --- a/DuckDuckGo/Bookmarks/Model/BookmarkManager.swift +++ b/DuckDuckGo/Bookmarks/Model/BookmarkManager.swift @@ -45,9 +45,6 @@ protocol BookmarkManager: AnyObject { func moveFavorites(with objectUUIDs: [String], toIndex: Int?, completion: @escaping (Error?) -> Void) func importBookmarks(_ bookmarks: ImportedBookmarks, source: BookmarkImportSource) -> BookmarkImportResult - func cleanUpBookmarksDatabase() - func updateBookmarkDatabaseCleanupSchedule(shouldEnable: Bool) - // Wrapper definition in a protocol is not supported yet var listPublisher: Published.Publisher { get } var list: BookmarkList? { get } @@ -65,12 +62,6 @@ final class LocalBookmarkManager: BookmarkManager { self.faviconManagement = faviconManagement } - let bookmarkDatabaseCleaner = BookmarkDatabaseCleaner( - bookmarkDatabase: BookmarkDatabase.shared.db, - errorEvents: BookmarksCleanupErrorHandling(), - log: .bookmarks - ) - @Published private(set) var list: BookmarkList? var listPublisher: Published.Publisher { $list } @@ -79,19 +70,6 @@ final class LocalBookmarkManager: BookmarkManager { // MARK: - Bookmarks - func updateBookmarkDatabaseCleanupSchedule(shouldEnable: Bool) { - bookmarkDatabaseCleaner.cleanUpDatabaseNow() - if shouldEnable { - bookmarkDatabaseCleaner.scheduleRegularCleaning() - } else { - bookmarkDatabaseCleaner.cancelCleaningSchedule() - } - } - - func cleanUpBookmarksDatabase() { - bookmarkDatabaseCleaner.cleanUpDatabaseNow() - } - func loadBookmarks() { bookmarkStore.loadAll(type: .topLevelEntities) { [weak self] (topLevelEntities, error) in guard error == nil, let topLevelEntities = topLevelEntities else { diff --git a/DuckDuckGo/Fire/Model/Fire.swift b/DuckDuckGo/Fire/Model/Fire.swift index 9a449ab7b2..86e2b5debd 100644 --- a/DuckDuckGo/Fire/Model/Fire.swift +++ b/DuckDuckGo/Fire/Model/Fire.swift @@ -38,6 +38,7 @@ final class Fire { let pinnedTabsManager: PinnedTabsManager let bookmarkManager: BookmarkManager let syncService: DDGSyncing? + let syncDataProviders: SyncDataProviders? let tabCleanupPreparer = TabCleanupPreparer() let secureVaultFactory: AutofillVaultFactory let tld: TLD @@ -96,6 +97,7 @@ final class Fire { tld: TLD, bookmarkManager: BookmarkManager = LocalBookmarkManager.shared, syncService: DDGSyncing? = nil, + syncDataProviders: SyncDataProviders? = nil, secureVaultFactory: AutofillVaultFactory = AutofillSecureVaultFactory ) { self.webCacheManager = cacheManager @@ -108,6 +110,7 @@ final class Fire { self.pinnedTabsManager = pinnedTabsManager ?? WindowControllersManager.shared.pinnedTabsManager self.bookmarkManager = bookmarkManager self.syncService = syncService ?? (NSApp.delegate as? AppDelegate)?.syncService + self.syncDataProviders = syncDataProviders ?? (NSApp.delegate as? AppDelegate)?.syncDataProviders self.secureVaultFactory = secureVaultFactory self.tld = tld @@ -519,7 +522,7 @@ final class Fire { private func burnDeletedBookmarks() { if syncService?.authState == .inactive { - bookmarkManager.cleanUpBookmarksDatabase() + syncDataProviders?.bookmarksAdapter.databaseCleaner.cleanUpDatabaseNow() } } } diff --git a/DuckDuckGo/Sync/CredentialsCleanupErrorHandling.swift b/DuckDuckGo/Sync/CredentialsCleanupErrorHandling.swift index bf5a66377a..cac2ff4cee 100644 --- a/DuckDuckGo/Sync/CredentialsCleanupErrorHandling.swift +++ b/DuckDuckGo/Sync/CredentialsCleanupErrorHandling.swift @@ -25,7 +25,7 @@ public class CredentialsCleanupErrorHandling: EventMapping Bool { return false