Bug 1250203 - Re-populate recent bookmarks when a bookmark gets deleted while the menu is open. r=mak

This commit is contained in:
Dão Gottwald 2016-05-04 16:52:40 +02:00
Родитель 53f074e796
Коммит ab3bd282d9
1 изменённых файлов: 16 добавлений и 0 удалений

Просмотреть файл

@ -1379,6 +1379,19 @@ var BookmarkingUI = {
this._populateRecentBookmarks(aHeaderItem, aExtraCSSClass);
};
this._recentlyBookmarkedObserver = {
QueryInterface: XPCOMUtils.generateQI([
Ci.nsINavBookmarkObserver,
Ci.nsISupportsWeakReference
])
};
this._recentlyBookmarkedObserver.onItemRemoved = () => {
// Update the menu when a bookmark has been removed.
// The native menubar on Mac doesn't support live update, so this won't
// work there.
this._populateRecentBookmarks(aHeaderItem, aExtraCSSClass);
};
let updatePlacesContextMenu = (shouldHidePrefUI = false) => {
let prefEnabled = !shouldHidePrefUI && Services.prefs.getBoolPref(this.RECENTLY_BOOKMARKED_PREF);
document.getElementById("placesContext_showRecentlyBookmarked").hidden = shouldHidePrefUI || prefEnabled;
@ -1402,12 +1415,15 @@ var BookmarkingUI = {
updatePlacesContextMenu(true);
Services.prefs.removeObserver(this.RECENTLY_BOOKMARKED_PREF, prefObserver, false);
PlacesUtils.bookmarks.removeObserver(this._recentlyBookmarkedObserver);
this._recentlyBookmarkedObserver = null;
placesContextMenu.removeEventListener("popupshowing", onPlacesContextMenuShowing);
bookmarksMenu.removeEventListener("popuphidden", onBookmarksMenuHidden);
}
};
Services.prefs.addObserver(this.RECENTLY_BOOKMARKED_PREF, prefObserver, false);
PlacesUtils.bookmarks.addObserver(this._recentlyBookmarkedObserver, true);
placesContextMenu.addEventListener("popupshowing", onPlacesContextMenuShowing);
bookmarksMenu.addEventListener("popuphidden", onBookmarksMenuHidden);
},