Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Fix #3332: Fixing Bookmarklet URLs (#3349)
Browse files Browse the repository at this point in the history
  • Loading branch information
Brandon-T authored Feb 24, 2021
1 parent 7e5af3b commit 456b0e2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,12 @@ class AddEditBookmarkTableViewController: UITableViewController {

switch saveLocation {
case .rootLevel:
bookmark.updateWithNewLocation(customTitle: title, url: url.absoluteString, location: nil)
bookmark.updateWithNewLocation(customTitle: title, url: url, location: nil)
case .favorites:
bookmark.delete()
Favorite.add(url: url, title: title)
case .folder(let folder):
bookmark.updateWithNewLocation(customTitle: title, url: urlString, location: folder)
bookmark.updateWithNewLocation(customTitle: title, url: url, location: folder)
}

case .editFolder(let folder):
Expand Down Expand Up @@ -301,7 +301,7 @@ class AddEditBookmarkTableViewController: UITableViewController {
favorite.delete()
Bookmarkv2.add(url: url, title: title)
case .favorites:
favorite.update(customTitle: title, url: url.absoluteString)
favorite.update(customTitle: title, url: url)
case .folder(let folder):
favorite.delete()
Bookmarkv2.add(url: url, title: title, parentFolder: folder)
Expand Down
16 changes: 8 additions & 8 deletions Client/Frontend/Sync/BraveCore/Bookmarkv2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,12 @@ extension Bookmarkv2 {
.compactMap({ return !$0.isFolder ? Bookmarkv2($0) : nil })
}

public func update(customTitle: String?, url: String?) {
public func update(customTitle: String?, url: URL?) {
bookmarkNode.setTitle(customTitle ?? "")
bookmarkNode.url = URL(string: url ?? "")
bookmarkNode.url = url
}

public func updateWithNewLocation(customTitle: String?, url: String?, location: Bookmarkv2?) {
public func updateWithNewLocation(customTitle: String?, url: URL?, location: Bookmarkv2?) {
if let location = location?.bookmarkNode ?? Bookmarkv2.bookmarksAPI.mobileNode {
if location.guid != bookmarkNode.parent?.guid {
bookmarkNode.move(toParent: location)
Expand All @@ -249,7 +249,7 @@ extension Bookmarkv2 {
}

if let url = url, !bookmarkNode.isFolder {
bookmarkNode.url = URL(string: url)
bookmarkNode.url = url
} else if url != nil {
log.error("Error: Moving bookmark - Cannot convert a folder into a bookmark with url.")
}
Expand All @@ -272,10 +272,10 @@ extension Bookmarkv2 {
node.move(toParent: parent, index: UInt(destinationIndexPath.row))
}

//Notify the delegate that items did move..
//This is already done automatically in `Bookmarkv2Fetcher` listener.
//However, the Brave-Core delegate is being called before the move is actually complete OR too quickly
//So to fix it, we reload here AFTER the move is done so the UI can update accordingly.
// Notify the delegate that items did move..
// This is already done automatically in `Bookmarkv2Fetcher` listener.
// However, the Brave-Core delegate is being called before the move is actually complete OR too quickly
// So to fix it, we reload here AFTER the move is done so the UI can update accordingly.
frc.delegate?.controllerDidReloadContents(frc)
}
}
Expand Down

0 comments on commit 456b0e2

Please sign in to comment.