Skip to content

Commit

Permalink
Reset bookmarks sync timestamp after migrating to FFS favorites
Browse files Browse the repository at this point in the history
  • Loading branch information
ayoy committed Oct 13, 2023
1 parent bb2834c commit fa4f02b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
10 changes: 9 additions & 1 deletion Core/SyncBookmarksAdapter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ public final class SyncBookmarksAdapter {
public private(set) var provider: BookmarksProvider?
public let databaseCleaner: BookmarkDatabaseCleaner
public let syncDidCompletePublisher: AnyPublisher<Void, Never>
public let widgetRefreshCancellable: AnyCancellable
public var shouldResetBookmarksSyncTimestamp: Bool = false {
willSet {
assert(provider == nil, "Setting this value has no effect after provider has been instantiated")
}
}

public init(database: CoreDataDatabase, favoritesDisplayModeStorage: FavoritesDisplayModeStoring) {
self.database = database
Expand Down Expand Up @@ -73,6 +77,9 @@ public final class SyncBookmarksAdapter {
syncDidCompleteSubject.send()
}
)
if shouldResetBookmarksSyncTimestamp {
provider.lastSyncTimestamp = nil
}

syncErrorCancellable = provider.syncErrorPublisher
.sink { error in
Expand Down Expand Up @@ -116,6 +123,7 @@ public final class SyncBookmarksAdapter {

private var syncDidCompleteSubject = PassthroughSubject<Void, Never>()
private var syncErrorCancellable: AnyCancellable?
private var widgetRefreshCancellable: AnyCancellable
private let database: CoreDataDatabase
private let favoritesDisplayModeStorage: FavoritesDisplayModeStoring
}
3 changes: 2 additions & 1 deletion DuckDuckGo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
DatabaseMigration.migrate(to: context)
}

bookmarksDatabase.loadStore { context, error in
bookmarksDatabase.loadStore { [weak self] context, error in
guard let context = context else {
if let error = error {
Pixel.fire(pixel: .bookmarksCouldNotLoadDatabase,
Expand All @@ -164,6 +164,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
BookmarkUtils.migrateToFormFactorSpecificFavorites(byCopyingExistingTo: .mobile, in: context)
if context.hasChanges {
try context.save(onErrorFire: .bookmarksMigrationCouldNotPrepareMultipleFavoriteFolders)
self?.syncDataProviders.bookmarksAdapter.shouldResetBookmarksSyncTimestamp = true
}
} catch {
Thread.sleep(forTimeInterval: 1)
Expand Down

0 comments on commit fa4f02b

Please sign in to comment.