Set the predecessorid when creating records for upload.

This commit is contained in:
Edward Lee 2009-08-16 12:39:00 -07:00
parent 24b24d90a8
commit a899e3fc64
2 changed files with 15 additions and 3 deletions

View File

@ -541,14 +541,15 @@ BookmarksStore.prototype = {
}
record.id = guid;
record.parentid = this._getParentGUIDForItemId(placeId);
record.parentid = this._getParentGUIDForId(placeId);
record.predecessorid = this._getPredecessorGUIDForId(placeId);
record.encryption = cryptoMetaURL;
this.cache.put(guid, record);
return record;
},
_getParentGUIDForItemId: function BStore__getParentGUIDForItemId(itemId) {
_getParentGUIDForId: function BStore__getParentGUIDForId(itemId) {
let parentid = this._bms.getFolderIdForItem(itemId);
if (parentid == -1) {
this._log.debug("Found orphan bookmark, reparenting to unfiled");
@ -558,6 +559,17 @@ BookmarksStore.prototype = {
return GUIDForId(parentid);
},
_getPredecessorGUIDForId: function BStore__getPredecessorGUIDForId(itemId) {
// Figure out the predecessor, unless it's the first item
let itemPos = Svc.Bookmark.getItemIndex(itemId);
if (itemPos == 0)
return;
let parentId = Svc.Bookmark.getFolderIdForItem(itemId);
let predecessorId = Svc.Bookmark.getIdForItemAt(parentId, itemPos - 1);
return GUIDForId(predecessorId);
},
_getChildren: function BStore_getChildren(guid, items) {
let node = guid; // the recursion case
if (typeof(node) == "string") // callers will give us the guid as the first arg

View File

@ -93,7 +93,7 @@ PlacesItem.prototype = {
},
};
Utils.deferGetSet(PlacesItem, "cleartext", "type");
Utils.deferGetSet(PlacesItem, "cleartext", ["predecessorid", "type"]);
function Bookmark(uri) {
this._Bookmark_init(uri);