Skip to content

Commit

Permalink
Fix mozilla-mobile#4717 - Provide feedback when pinning a site from i…
Browse files Browse the repository at this point in the history
…nside the Library panel

Display toast notification on the Library panel
Display toast notification on the Bookmarks panel
Display toast notification on the Website tab
  • Loading branch information
Vlad Dramaretskyi authored and dnarcese committed Jun 16, 2020
1 parent 63390d9 commit 930db01
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
6 changes: 5 additions & 1 deletion Client/Frontend/Library/BookmarksPanel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,11 @@ extension BookmarksPanel: LibraryPanelContextMenu {
}

let pinTopSite = PhotonActionSheetItem(title: Strings.PinTopsiteActionTitle, iconString: "action_pin", handler: { _, _ in
_ = self.profile.history.addPinnedTopSite(site)
_ = self.profile.history.addPinnedTopSite(site).uponQueue(.main) { result in
if result.isSuccess {
SimpleToast().showAlertWithText(Strings.AppMenuAddPinToTopSitesConfirmMessage, bottomContainer: self.view)
}
}
})
actions.append(pinTopSite)

Expand Down
6 changes: 5 additions & 1 deletion Client/Frontend/Library/HistoryPanel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,11 @@ class HistoryPanel: SiteTableViewController, LibraryPanel {
}

func pinToTopSites(_ site: Site) {
_ = profile.history.addPinnedTopSite(site).value
_ = profile.history.addPinnedTopSite(site).uponQueue(.main) { result in
if result.isSuccess {
SimpleToast().showAlertWithText(Strings.AppMenuAddPinToTopSitesConfirmMessage, bottomContainer: self.view)
}
}
}

func navigateToRecentlyClosed() {
Expand Down
2 changes: 2 additions & 0 deletions Client/Frontend/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,8 @@ extension Strings {
public static let AppMenuAddBookmarkConfirmMessage = NSLocalizedString("Menu.AddBookmark.Confirm", value: "Bookmark Added", comment: "Toast displayed to the user after a bookmark has been added.")
public static let AppMenuTabSentConfirmMessage = NSLocalizedString("Menu.TabSent.Confirm", value: "Tab Sent", comment: "Toast displayed to the user after a tab has been sent successfully.")
public static let AppMenuRemoveBookmarkConfirmMessage = NSLocalizedString("Menu.RemoveBookmark.Confirm", value: "Bookmark Removed", comment: "Toast displayed to the user after a bookmark has been removed.")
public static let AppMenuAddPinToTopSitesConfirmMessage = NSLocalizedString("Menu.AddPin.Confirm", value: "Pinned To Top Sites", comment: "Toast displayed to the user after adding the item to the Top Sites.")
public static let AppMenuRemovePinFromTopSitesConfirmMessage = NSLocalizedString("Menu.RemovePin.Confirm", value: "Removed From Top Sites", comment: "Toast displayed to the user after removing the item from the Top Sites.")
public static let AppMenuAddToReadingListConfirmMessage = NSLocalizedString("Menu.AddToReadingList.Confirm", value: "Added To Reading List", comment: "Toast displayed to the user after adding the item to their reading list.")
public static let SendToDeviceTitle = NSLocalizedString("Send to Device", tableName: "3DTouchActions", comment: "Label for preview action on Tab Tray Tab to send the current tab to another device")
public static let PageActionMenuTitle = NSLocalizedString("Menu.PageActions.Title", value: "Page Actions", comment: "Label for title in page action menu.")
Expand Down
13 changes: 10 additions & 3 deletions Client/Frontend/Widgets/PhotonActionSheet/PageActionMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,12 @@ extension PhotonActionSheetProtocol {
guard let site = val.successValue?.asArray().first?.flatMap({ $0 }) else {
return succeed()
}

return self.profile.history.addPinnedTopSite(site)
}.uponQueue(.main) { _ in }
}.uponQueue(.main) { result in
if result.isSuccess {
success(Strings.AppMenuAddPinToTopSitesConfirmMessage)
}
}
}

let removeTopSitesPin = PhotonActionSheetItem(title: Strings.RemovePinTopsiteActionTitle, iconString: "action_unpin") { _, _ in
Expand All @@ -111,7 +114,11 @@ extension PhotonActionSheetProtocol {
}

return self.profile.history.removeFromPinnedTopSites(site)
}.uponQueue(.main) { _ in }
}.uponQueue(.main) { result in
if result.isSuccess {
success(Strings.AppMenuAddPinToTopSitesConfirmMessage)
}
}
}

let sendToDevice = PhotonActionSheetItem(title: Strings.SendToDeviceTitle, iconString: "menu-Send-to-Device") { _, _ in
Expand Down

0 comments on commit 930db01

Please sign in to comment.