Bug 503938 - Tags with a single bookmark keep generating new tag ids

Share a tagging code for create/update that will tag a dummy uri temporarily while it untags the bookmark to make sure every tag has at least one child during this untag/tag process.
This commit is contained in:
Edward Lee 2009-07-13 13:40:49 -07:00
parent 6b52988511
commit 22570f2932

View File

@ -200,8 +200,7 @@ BookmarksStore.prototype = {
this._log.debug(" -> -> title is " + record.title);
newId = this._bms.insertBookmark(parentId, uri, record.sortindex,
record.title);
this._ts.untagURI(uri, null);
this._ts.tagURI(uri, record.tags);
this._tagURI(uri, record.tags);
this._bms.setKeywordForBookmark(newId, record.keyword);
if (record.description) {
this._ans.setItemAnnotation(newId, "bookmarkProperties/description",
@ -361,13 +360,9 @@ BookmarksStore.prototype = {
case "bmkUri":
this._bms.changeBookmarkURI(itemId, Utils.makeURI(val));
break;
case "tags": {
// filter out null/undefined/empty tags
let tags = val.filter(function(t) t);
let tagsURI = this._bms.getBookmarkURI(itemId);
this._ts.untagURI(tagsURI, null);
this._ts.tagURI(tagsURI, tags);
} break;
case "tags":
this._tagURI(this._bms.getBookmarkURI(itemId), val);
break;
case "keyword":
this._bms.setKeywordForBookmark(itemId, val);
break;
@ -617,6 +612,18 @@ BookmarksStore.prototype = {
return items;
},
_tagURI: function BStore_tagURI(bmkURI, tags) {
// Filter out any null/undefined/empty tags
tags = tags.filter(function(t) t);
// Temporarily tag a dummy uri to preserve tag ids when untagging
let dummyURI = Utils.makeURI("about:weave");
this._ts.tagURI(dummyURI, tags);
this._ts.untagURI(bmkURI, null);
this._ts.tagURI(bmkURI, tags);
this._ts.untagURI(dummyURI, null);
},
getAllIDs: function BStore_getAllIDs() {
let items = {};