diff --git a/content/bookmarks.js b/content/bookmarks.js index bd6f9160..2ebb08a9 100644 --- a/content/bookmarks.js +++ b/content/bookmarks.js @@ -94,6 +94,31 @@ liberator.Bookmarks = function () //{{{ } } + function flush() + { + bookmarks = null; + if (liberator.options["preload"]) + load(); + } + + var observer = { + onBeginUpdateBatch: function() {}, + onEndUpdateBatch: function() {}, + onItemVisited: function() {}, + /* FIXME: Should probably just update the given bookmark. */ + onItemMoved: flush, + onItemAdded: flush, + onItemRemoved: flush, + onItemChanged: flush, + QueryInterface: function(iid) { + if (iid.equals(Components.interfaces.nsINavBookmarkObserver) || iid.equals(Components.interfaces.nsISupports)) + return this; + throw Components.results.NS_ERROR_NO_INTERFACE; + } + }; + + bookmarksService.addObserver(observer, false); + /////////////////////////////////////////////////////////////////////////////}}} ////////////////////// OPTIONS ///////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ @@ -275,9 +300,6 @@ liberator.Bookmarks = function () //{{{ // update the display of our "bookmarked" symbol liberator.statusline.updateUrl(); - //also update bookmark cache - bookmarks.unshift([url, title, keyword, tags || []]); - liberator.autocommands.trigger("BookmarkAdd", ""); return true; @@ -342,10 +364,6 @@ liberator.Bookmarks = function () //{{{ return i; } - // also update bookmark cache, if we removed at least one bookmark - if (count.value > 0) - load(); - // update the display of our "bookmarked" symbol liberator.statusline.updateUrl(); @@ -472,8 +490,12 @@ liberator.Bookmarks = function () //{{{ list += ""; liberator.commandline.echo(list, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE); - } + }, + destroy: function() + { + bookmarksService.removeObserver(observer, false); + }, }; //}}} }; //}}} diff --git a/content/liberator.js b/content/liberator.js index 6fc767d0..cea979a7 100644 --- a/content/liberator.js +++ b/content/liberator.js @@ -1093,6 +1093,8 @@ const liberator = (function () //{{{ liberator.events.destroy(); if (liberator.has("quickmarks")) liberator.quickmarks.destroy(); + if (liberator.has("bookmarks")) + liberator.bookmarks.destroy(); liberator.dump("All liberator modules destroyed\n");