Skip to content

Commit

Permalink
Bugfix FXIOS-7446 [v121] Incorrect bookmark title is saved when user …
Browse files Browse the repository at this point in the history
…is undoing a bookmark deletion (mozilla-mobile#16501)
  • Loading branch information
Stefan Vladut committed Nov 14, 2023
1 parent e830daa commit db92bc1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Client/Frontend/Browser/BrowserViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,7 @@ class BrowserViewController: UIViewController,
func removeBookmark(url: String) {
profile.places.deleteBookmarksWithURL(url: url).uponQueue(.main) { result in
guard result.isSuccess else { return }
self.showToast(message: .AppMenu.RemoveBookmarkConfirmMessage, toastAction: .removeBookmark, url: url)
self.showToast(message: .AppMenu.RemoveBookmarkConfirmMessage, toastAction: .removeBookmark)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,15 +212,16 @@ extension BrowserViewController: ToolBarActionMenuDelegate {
presentWithModalDismissIfNeeded(viewController, animated: true)
}

func showToast(message: String, toastAction: MenuButtonToastAction, url: String?) {
func showToast(message: String, toastAction: MenuButtonToastAction) {
switch toastAction {
case .removeBookmark:
let viewModel = ButtonToastViewModel(labelText: message,
buttonText: .UndoString,
textAlignment: .left)
let toast = ButtonToast(viewModel: viewModel,
theme: themeManager.currentTheme) { isButtonTapped in
isButtonTapped ? self.addBookmark(url: url ?? "") : nil
theme: themeManager.currentTheme) { [weak self] isButtonTapped in
guard let strongSelf = self, let currentTab = strongSelf.tabManager.selectedTab else { return }
isButtonTapped ? strongSelf.addBookmark(url: currentTab.url?.absoluteString ?? "", title: currentTab.title) : nil
}
show(toast: toast)
default:
Expand Down
15 changes: 7 additions & 8 deletions Client/Frontend/Browser/MainMenuActionHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protocol ToolBarActionMenuDelegate: AnyObject {

func showLibrary(panel: LibraryPanelType)
func showViewController(viewController: UIViewController)
func showToast(message: String, toastAction: MenuButtonToastAction, url: String?)
func showToast(message: String, toastAction: MenuButtonToastAction)
func showMenuPresenter(url: URL, tab: Tab, view: UIView)
func showFindInPage()
func showCustomizeHomePage()
Expand Down Expand Up @@ -378,7 +378,7 @@ class MainMenuActionHelper: PhotonActionSheetProtocol,
TelemetryWrapper.recordEvent(category: .action, method: .tap, object: .copyAddress)
if let url = self.selectedTab?.canonicalURL?.displayURL {
UIPasteboard.general.url = url
self.delegate?.showToast(message: .AppMenu.AppMenuCopyURLConfirmMessage, toastAction: .copyUrl, url: nil)
self.delegate?.showToast(message: .AppMenu.AppMenuCopyURLConfirmMessage, toastAction: .copyUrl)
}
}.items
}
Expand Down Expand Up @@ -670,7 +670,7 @@ class MainMenuActionHelper: PhotonActionSheetProtocol,

self.profile.readingList.createRecordWithURL(url.absoluteString, title: tab.title ?? "", addedBy: UIDevice.current.name)
TelemetryWrapper.recordEvent(category: .action, method: .add, object: .readingListItem, value: .pageActionMenu)
self.delegate?.showToast(message: .AppMenu.AddToReadingListConfirmMessage, toastAction: .addToReadingList, url: nil)
self.delegate?.showToast(message: .AppMenu.AddToReadingListConfirmMessage, toastAction: .addToReadingList)
}
}

Expand All @@ -683,8 +683,7 @@ class MainMenuActionHelper: PhotonActionSheetProtocol,

self.profile.readingList.deleteRecord(record, completion: nil)
self.delegate?.showToast(message: .AppMenu.RemoveFromReadingListConfirmMessage,
toastAction: .removeFromReadingList,
url: nil)
toastAction: .removeFromReadingList)
TelemetryWrapper.recordEvent(category: .action,
method: .delete,
object: .readingListItem,
Expand Down Expand Up @@ -737,7 +736,7 @@ class MainMenuActionHelper: PhotonActionSheetProtocol,

self.profile.places.deleteBookmarksWithURL(url: url.absoluteString).uponQueue(.main) { result in
guard result.isSuccess else { return }
self.delegate?.showToast(message: .AppMenu.RemoveBookmarkConfirmMessage, toastAction: .removeBookmark, url: url.absoluteString)
self.delegate?.showToast(message: .AppMenu.RemoveBookmarkConfirmMessage, toastAction: .removeBookmark)
self.removeBookmarkShortcut()
}

Expand All @@ -759,7 +758,7 @@ class MainMenuActionHelper: PhotonActionSheetProtocol,
let site = Site(url: url.absoluteString, title: title)
self.profile.pinnedSites.addPinnedTopSite(site).uponQueue(.main) { result in
guard result.isSuccess else { return }
self.delegate?.showToast(message: .AppMenu.AddPinToShortcutsConfirmMessage, toastAction: .pinPage, url: nil)
self.delegate?.showToast(message: .AppMenu.AddPinToShortcutsConfirmMessage, toastAction: .pinPage)
}

TelemetryWrapper.recordEvent(category: .action, method: .tap, object: .pinToTopSites)
Expand All @@ -774,7 +773,7 @@ class MainMenuActionHelper: PhotonActionSheetProtocol,
let site = Site(url: url.absoluteString, title: title)
self.profile.pinnedSites.removeFromPinnedTopSites(site).uponQueue(.main) { result in
if result.isSuccess {
self.delegate?.showToast(message: .AppMenu.RemovePinFromShortcutsConfirmMessage, toastAction: .removePinPage, url: nil)
self.delegate?.showToast(message: .AppMenu.RemovePinFromShortcutsConfirmMessage, toastAction: .removePinPage)
}
}
TelemetryWrapper.recordEvent(category: .action, method: .tap, object: .removePinnedSite)
Expand Down

0 comments on commit db92bc1

Please sign in to comment.