Skip to content

Commit

Permalink
Revert "Fix brave#450, create resolved bookmarks from the oldest to n…
Browse files Browse the repository at this point in the history
…ewest by syncTimestamp."

This reverts commit f85839a.
  • Loading branch information
iccub committed Jan 16, 2019
1 parent 79def12 commit eae5676
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions Data/sync/Sync.swift
Original file line number Diff line number Diff line change
Expand Up @@ -463,20 +463,12 @@ extension Sync {
guard var fetchedRecords = recordType.fetchedModelType?.syncRecords(recordJSON) else { return }

// Currently only prefs are device related
if recordType == .prefs {
if recordType == .prefs, let data = fetchedRecords as? [SyncDevice] {
// Devices have really bad data filtering, so need to manually process more of it
// Sort to not rely on API - Reverse sort, so unique pulls the `latest` not just the `first`
fetchedRecords = fetchedRecords.sorted { device1, device2 in
fetchedRecords = data.sorted { device1, device2 in
device1.syncTimestamp ?? -1 > device2.syncTimestamp ?? -1 }.unique { $0.objectId ?? [] == $1.objectId ?? [] }

} else if recordType == .bookmark {
// Bookmars are sorted to have the oldest bookmark to come in first, so it can be added before it's children.
fetchedRecords = fetchedRecords.sorted(by: {
let firstTimestamp = $0.syncTimestamp ?? 0
let secondTimestamp = $1.syncTimestamp ?? 0

return firstTimestamp < secondTimestamp
})
}

let context = DataController.newBackgroundContext()
Expand Down

0 comments on commit eae5676

Please sign in to comment.