1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-01-09 00:04:11 +01:00

Don't report live bookmark items as bookmarked.

This commit is contained in:
Kris Maglione
2009-10-09 00:17:57 -04:00
parent e62d9f96a5
commit 8b7b290e65
4 changed files with 28 additions and 25 deletions

View File

@@ -39,6 +39,7 @@ function Bookmarks() //{{{
const bookmarksService = PlacesUtils.bookmarks;
const taggingService = PlacesUtils.tagging;
const faviconService = services.get("favicon");
const livemarkService = services.get("livemark");
// XXX for strange Firefox bug :(
// Error: [Exception... "Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsIObserverService.addObserver]"
@@ -114,6 +115,18 @@ function Bookmarks() //{{{
this.isBookmark = function (id) rootFolders.indexOf(self.findRoot(id)) >= 0;
this.isRegularBookmark = function findRoot(id)
{
do
{
var root = id;
if (livemarkService && livemarkService.isLivemark(id))
return false;
id = bookmarksService.getFolderIdForItem(id);
} while (id != bookmarksService.placesRoot && id != root);
return rootFolders.indexOf(root) >= 0;
}
// since we don't use a threaded bookmark loading (by set preload)
// anymore, is this loading synchronization still needed? --mst
let loading = false;
@@ -389,11 +402,10 @@ function Bookmarks() //{{{
if (args.bang)
{
commandline.input("This will delete all bookmarks. Would you like to continue? (yes/[no]) ",
function (resp)
{
function (resp) {
if (resp && resp.match(/^y(es)?$/i))
{
bookmarks.get("").forEach(function (bmark) { bookmarks.remove(bmark.url); });
cache.bookmarks.forEach(function (bmark) { bookmarksService.removeItem(bmark.id); });
liberator.echomsg("All bookmarks deleted", 1, commandline.FORCE_SINGLELINE);
}
});
@@ -403,7 +415,7 @@ function Bookmarks() //{{{
let url = args.string || buffer.URL;
let deletedCount = bookmarks.remove(url);
liberator.echomsg(deletedCount + " bookmark(s) with url `" + url + "' deleted", 1, commandline.FORCE_SINGLELINE);
liberator.echomsg(deletedCount + " bookmark(s) with url " + url.quote() + " deleted", 1, commandline.FORCE_SINGLELINE);
}
},
@@ -587,7 +599,7 @@ function Bookmarks() //{{{
try
{
return bookmarksService.getBookmarkIdsForURI(makeURI(url), {})
.some(cache.isBookmark);
.some(cache.isRegularBookmark);
}
catch (e)
{
@@ -598,29 +610,19 @@ function Bookmarks() //{{{
// returns number of deleted bookmarks
remove: function remove(url)
{
if (!url)
return 0;
let i = 0;
try
{
let uri = util.newURI(url);
var count = {};
let bmarks = bookmarksService.getBookmarkIdsForURI(uri, count);
for (; i < bmarks.length; i++)
bookmarksService.removeItem(bmarks[i]);
let bmarks = bookmarksService.getBookmarkIdsForURI(uri, {})
.filter(cache.isRegularBookmark);
bmarks.forEach(bookmarksService.removeItem);
return bmarks.length;
}
catch (e)
{
liberator.log(e, 0);
return i;
return 0;
}
// update the display of our "bookmarked" symbol
statusline.updateUrl();
return count.value;
},
getFavicon: function (url) getFavicon(url),

View File

@@ -1661,7 +1661,7 @@ const liberator = (function () //{{{
{
let obj = {
toString: function () error.toString(),
stack: <>{error.stack.replace(/^/mg, "\t")}</>
stack: <>{(error.stack || Error().stack).replace(/^/mg, "\t")}</>
};
for (let [k, v] in Iterator(error))
{
@@ -1671,7 +1671,7 @@ const liberator = (function () //{{{
liberator.dump(obj);
liberator.dump("");
}
catch (e) {}
catch (e) { window.dump(e) }
},
/**

View File

@@ -97,6 +97,7 @@ function Services()
self.add("extensionManager", "@mozilla.org/extensions/manager;1", Ci.nsIExtensionManager);
self.add("favicon", "@mozilla.org/browser/favicon-service;1", Ci.nsIFaviconService);
self.add("json", "@mozilla.org/dom/json;1", Ci.nsIJSON, "createInstance");
self.add("livemark", "@mozilla.org/browser/livemark-service;2", Ci.nsILivemarkService);
self.add("observer", "@mozilla.org/observer-service;1", Ci.nsIObserverService);
self.add("io", "@mozilla.org/network/io-service;1", Ci.nsIIOService);
self.add("pref", "@mozilla.org/preferences-service;1", [Ci.nsIPrefService, Ci.nsIPrefBranch, Ci.nsIPrefBranch2]);

View File

@@ -308,10 +308,10 @@ var storage = {
alwaysReload: {},
newObject: function newObject(key, constructor, store, type, options, reload)
{
if (!(key in keys) || reload || key in this.alwaysReload)
if (!(key in keys) || reload || this.alwaysReload[key])
{
if (key in this && !reload)
throw Error;
if (key in this && !(reload || this.alwaysReload[key]))
throw Error();
let load = function () loadPref(key, store, type || Object);
keys[key] = new constructor(key, store, load, options || {});
timers[key] = new Timer(1000, 10000, function () storage.save(key));