mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 17:12:28 +01:00
Update bookmarks cache based on bookmarks observer.
This commit is contained in:
@@ -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 /////////////////////////////////////////////////
|
////////////////////// OPTIONS /////////////////////////////////////////////////
|
||||||
/////////////////////////////////////////////////////////////////////////////{{{
|
/////////////////////////////////////////////////////////////////////////////{{{
|
||||||
@@ -275,9 +300,6 @@ liberator.Bookmarks = function () //{{{
|
|||||||
// update the display of our "bookmarked" symbol
|
// update the display of our "bookmarked" symbol
|
||||||
liberator.statusline.updateUrl();
|
liberator.statusline.updateUrl();
|
||||||
|
|
||||||
//also update bookmark cache
|
|
||||||
bookmarks.unshift([url, title, keyword, tags || []]);
|
|
||||||
|
|
||||||
liberator.autocommands.trigger("BookmarkAdd", "");
|
liberator.autocommands.trigger("BookmarkAdd", "");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -342,10 +364,6 @@ liberator.Bookmarks = function () //{{{
|
|||||||
return i;
|
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
|
// update the display of our "bookmarked" symbol
|
||||||
liberator.statusline.updateUrl();
|
liberator.statusline.updateUrl();
|
||||||
|
|
||||||
@@ -472,8 +490,12 @@ liberator.Bookmarks = function () //{{{
|
|||||||
list += "</table>";
|
list += "</table>";
|
||||||
|
|
||||||
liberator.commandline.echo(list, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE);
|
liberator.commandline.echo(list, liberator.commandline.HL_NORMAL, liberator.commandline.FORCE_MULTILINE);
|
||||||
}
|
},
|
||||||
|
|
||||||
|
destroy: function()
|
||||||
|
{
|
||||||
|
bookmarksService.removeObserver(observer, false);
|
||||||
|
},
|
||||||
};
|
};
|
||||||
//}}}
|
//}}}
|
||||||
}; //}}}
|
}; //}}}
|
||||||
|
|||||||
@@ -1093,6 +1093,8 @@ const liberator = (function () //{{{
|
|||||||
liberator.events.destroy();
|
liberator.events.destroy();
|
||||||
if (liberator.has("quickmarks"))
|
if (liberator.has("quickmarks"))
|
||||||
liberator.quickmarks.destroy();
|
liberator.quickmarks.destroy();
|
||||||
|
if (liberator.has("bookmarks"))
|
||||||
|
liberator.bookmarks.destroy();
|
||||||
|
|
||||||
liberator.dump("All liberator modules destroyed\n");
|
liberator.dump("All liberator modules destroyed\n");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user