1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-23 14:52:28 +01:00

Update bookmarks cache based on bookmarks observer.

This commit is contained in:
Kris Maglione
2008-09-10 19:36:30 +00:00
parent a6a9561bdd
commit ca6048ef05
2 changed files with 32 additions and 8 deletions

View File

@@ -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 += "</table>";
liberator.commandline.echo(list, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE);
}
},
destroy: function()
{
bookmarksService.removeObserver(observer, false);
},
};
//}}}
}; //}}}

View File

@@ -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");