Skip to content

Commit

Permalink
Fix: brave#787: Send deleted Bookmark to Sync after tapping on Bookma…
Browse files Browse the repository at this point in the history
…rk toggle button.
  • Loading branch information
iccub committed Jan 24, 2019
1 parent 27f8fdb commit 731b844
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions Data/models/Bookmark.swift
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,16 @@ public final class Bookmark: NSManagedObject, WebsitePresentable, Syncable, CRUD
delete()
}

/// Removes a single Bookmark of a given URL.
/// In case of having two bookmarks with the same url, a bookmark to delete is chosen randomly.
public class func remove(forUrl url: URL) {
let context = DataController.newBackgroundContext()
let predicate = isFavoriteOrBookmarkByUrlPredicate(url: url, getFavorites: false)

let record = first(where: predicate, context: context)
record?.remove()
}

private func removeFolderAndSendSyncRecords(uuid: [Int]?) {
if !isFolder { return }

Expand Down Expand Up @@ -452,14 +462,6 @@ extension Bookmark {
return all(where: predicate) ?? []
}

public class func remove(forUrl url: URL) {
let context = DataController.newBackgroundContext()
let predicate = isFavoriteOrBookmarkByUrlPredicate(url: url, getFavorites: false)

let record = first(where: predicate, context: context)
record?.delete()
}

/// Gets all nested bookmarks recursively.
public static func getRecursiveChildren(forFolderUUID syncUUID: [Int]?,
context: NSManagedObjectContext = DataController.viewContext) -> [Bookmark]? {
Expand Down

0 comments on commit 731b844

Please sign in to comment.