mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-03-06 22:45:46 +01:00
Don't report live bookmark items as bookmarked.
This commit is contained in:
@@ -39,6 +39,7 @@ function Bookmarks() //{{{
|
|||||||
const bookmarksService = PlacesUtils.bookmarks;
|
const bookmarksService = PlacesUtils.bookmarks;
|
||||||
const taggingService = PlacesUtils.tagging;
|
const taggingService = PlacesUtils.tagging;
|
||||||
const faviconService = services.get("favicon");
|
const faviconService = services.get("favicon");
|
||||||
|
const livemarkService = services.get("livemark");
|
||||||
|
|
||||||
// XXX for strange Firefox bug :(
|
// XXX for strange Firefox bug :(
|
||||||
// Error: [Exception... "Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsIObserverService.addObserver]"
|
// 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.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)
|
// since we don't use a threaded bookmark loading (by set preload)
|
||||||
// anymore, is this loading synchronization still needed? --mst
|
// anymore, is this loading synchronization still needed? --mst
|
||||||
let loading = false;
|
let loading = false;
|
||||||
@@ -389,11 +402,10 @@ function Bookmarks() //{{{
|
|||||||
if (args.bang)
|
if (args.bang)
|
||||||
{
|
{
|
||||||
commandline.input("This will delete all bookmarks. Would you like to continue? (yes/[no]) ",
|
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))
|
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);
|
liberator.echomsg("All bookmarks deleted", 1, commandline.FORCE_SINGLELINE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -403,7 +415,7 @@ function Bookmarks() //{{{
|
|||||||
let url = args.string || buffer.URL;
|
let url = args.string || buffer.URL;
|
||||||
let deletedCount = bookmarks.remove(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
|
try
|
||||||
{
|
{
|
||||||
return bookmarksService.getBookmarkIdsForURI(makeURI(url), {})
|
return bookmarksService.getBookmarkIdsForURI(makeURI(url), {})
|
||||||
.some(cache.isBookmark);
|
.some(cache.isRegularBookmark);
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
@@ -598,29 +610,19 @@ function Bookmarks() //{{{
|
|||||||
// returns number of deleted bookmarks
|
// returns number of deleted bookmarks
|
||||||
remove: function remove(url)
|
remove: function remove(url)
|
||||||
{
|
{
|
||||||
if (!url)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
let i = 0;
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
let uri = util.newURI(url);
|
let uri = util.newURI(url);
|
||||||
var count = {};
|
let bmarks = bookmarksService.getBookmarkIdsForURI(uri, {})
|
||||||
let bmarks = bookmarksService.getBookmarkIdsForURI(uri, count);
|
.filter(cache.isRegularBookmark);
|
||||||
|
bmarks.forEach(bookmarksService.removeItem);
|
||||||
for (; i < bmarks.length; i++)
|
return bmarks.length;
|
||||||
bookmarksService.removeItem(bmarks[i]);
|
|
||||||
}
|
}
|
||||||
catch (e)
|
catch (e)
|
||||||
{
|
{
|
||||||
liberator.log(e, 0);
|
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),
|
getFavicon: function (url) getFavicon(url),
|
||||||
|
|||||||
@@ -1661,7 +1661,7 @@ const liberator = (function () //{{{
|
|||||||
{
|
{
|
||||||
let obj = {
|
let obj = {
|
||||||
toString: function () error.toString(),
|
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))
|
for (let [k, v] in Iterator(error))
|
||||||
{
|
{
|
||||||
@@ -1671,7 +1671,7 @@ const liberator = (function () //{{{
|
|||||||
liberator.dump(obj);
|
liberator.dump(obj);
|
||||||
liberator.dump("");
|
liberator.dump("");
|
||||||
}
|
}
|
||||||
catch (e) {}
|
catch (e) { window.dump(e) }
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ function Services()
|
|||||||
self.add("extensionManager", "@mozilla.org/extensions/manager;1", Ci.nsIExtensionManager);
|
self.add("extensionManager", "@mozilla.org/extensions/manager;1", Ci.nsIExtensionManager);
|
||||||
self.add("favicon", "@mozilla.org/browser/favicon-service;1", Ci.nsIFaviconService);
|
self.add("favicon", "@mozilla.org/browser/favicon-service;1", Ci.nsIFaviconService);
|
||||||
self.add("json", "@mozilla.org/dom/json;1", Ci.nsIJSON, "createInstance");
|
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("observer", "@mozilla.org/observer-service;1", Ci.nsIObserverService);
|
||||||
self.add("io", "@mozilla.org/network/io-service;1", Ci.nsIIOService);
|
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]);
|
self.add("pref", "@mozilla.org/preferences-service;1", [Ci.nsIPrefService, Ci.nsIPrefBranch, Ci.nsIPrefBranch2]);
|
||||||
|
|||||||
@@ -308,10 +308,10 @@ var storage = {
|
|||||||
alwaysReload: {},
|
alwaysReload: {},
|
||||||
newObject: function newObject(key, constructor, store, type, options, reload)
|
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)
|
if (key in this && !(reload || this.alwaysReload[key]))
|
||||||
throw Error;
|
throw Error();
|
||||||
let load = function () loadPref(key, store, type || Object);
|
let load = function () loadPref(key, store, type || Object);
|
||||||
keys[key] = new constructor(key, store, load, options || {});
|
keys[key] = new constructor(key, store, load, options || {});
|
||||||
timers[key] = new Timer(1000, 10000, function () storage.save(key));
|
timers[key] = new Timer(1000, 10000, function () storage.save(key));
|
||||||
|
|||||||
Reference in New Issue
Block a user