mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Detect dupe separators by identifying them by their position and generate the lookup lazily with the folder/title mapping for now.
This commit is contained in:
parent
258a985cee
commit
87de5afcd8
@ -99,20 +99,40 @@ BookmarksEngine.prototype = {
|
||||
_syncStartup: function _syncStart() {
|
||||
SyncEngine.prototype._syncStartup.call(this);
|
||||
|
||||
// Lazily create a mapping of folder titles to ids if necessary
|
||||
this.__defineGetter__("_folderTitles", function() {
|
||||
// Lazily create a mapping of folder titles and separator positions to GUID
|
||||
let lazyMap = function() {
|
||||
delete this._folderTitles;
|
||||
delete this._separatorPos;
|
||||
|
||||
let folderTitles = {};
|
||||
let separatorPos = {};
|
||||
for (let guid in this._store.getAllIDs()) {
|
||||
let id = idForGUID(guid);
|
||||
if (Svc.Bookmark.getItemType(id) != Svc.Bookmark.TYPE_FOLDER)
|
||||
continue;
|
||||
|
||||
folderTitles[Svc.Bookmark.getItemTitle(id)] = guid;
|
||||
switch (Svc.Bookmark.getItemType(id)) {
|
||||
case Svc.Bookmark.TYPE_FOLDER:
|
||||
// Map the folder name to GUID
|
||||
folderTitles[Svc.Bookmark.getItemTitle(id)] = guid;
|
||||
break;
|
||||
case Svc.Bookmark.TYPE_SEPARATOR:
|
||||
// Map the separator position and parent position to GUID
|
||||
let parent = Svc.Bookmark.getFolderIdForItem(id);
|
||||
let pos = [id, parent].map(Svc.Bookmark.getItemIndex);
|
||||
separatorPos[pos] = guid;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return this._folderTitles = folderTitles;
|
||||
});
|
||||
|
||||
this._folderTitles = folderTitles;
|
||||
this._separatorPos = separatorPos;
|
||||
};
|
||||
|
||||
// Make the getters that lazily build the mapping
|
||||
["_folderTitles", "_separatorPos"].forEach(function(lazy) {
|
||||
this.__defineGetter__(lazy, function() {
|
||||
lazyMap.call(this);
|
||||
return this[lazy];
|
||||
});
|
||||
}, this);
|
||||
},
|
||||
|
||||
_syncFinish: function _syncFinish() {
|
||||
@ -134,6 +154,8 @@ BookmarksEngine.prototype = {
|
||||
case "folder":
|
||||
case "livemark":
|
||||
return this._folderTitles[item.title];
|
||||
case "separator":
|
||||
return this._separatorPos[item.pos];
|
||||
}
|
||||
// TODO for bookmarks, check if it exists and find guid
|
||||
// for everything else (folders, separators) look for parent/pred?
|
||||
@ -717,6 +739,9 @@ BookmarksStore.prototype = {
|
||||
|
||||
case this._bms.TYPE_SEPARATOR:
|
||||
record = new BookmarkSeparator();
|
||||
// Create a positioning identifier for the separator
|
||||
let parent = Svc.Bookmark.getFolderIdForItem(placeId);
|
||||
record.pos = [placeId, parent].map(Svc.Bookmark.getItemIndex);
|
||||
break;
|
||||
|
||||
case this._bms.TYPE_DYNAMIC_CONTAINER:
|
||||
|
@ -183,3 +183,5 @@ BookmarkSeparator.prototype = {
|
||||
this.type = "separator";
|
||||
}
|
||||
};
|
||||
|
||||
Utils.deferGetSet(BookmarkSeparator, "cleartext", "pos");
|
||||
|
Loading…
Reference in New Issue
Block a user