mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
decrypt incoming items all in one go so as to sort them by index (which is inside the payload); don't attempt to change the index of an item if we're also changing its folder; only change index/parent if it's different from current value
This commit is contained in:
parent
d1b0cb3caf
commit
c221d2ea8e
@ -382,7 +382,7 @@ NewEngine.prototype = {
|
||||
}
|
||||
}
|
||||
|
||||
// STEP 2: Find new items from server, place into incoming queue
|
||||
// STEP 2.1: Find new items from server, place into incoming queue
|
||||
this._log.debug("Downloading server changes");
|
||||
|
||||
let newitems = new Collection(this.engineURL);
|
||||
@ -395,9 +395,10 @@ NewEngine.prototype = {
|
||||
this.incoming.push(item);
|
||||
}
|
||||
|
||||
// STEP 2.5: Analyze incoming records and sort them
|
||||
// STEP 2.2: Decrypt items, then analyze incoming records and sort them
|
||||
for each (let inc in this.incoming) {
|
||||
this._recDepth(inc);
|
||||
yield inc.decrypt(self.cb, ID.get('WeaveCryptoID').password);
|
||||
this._recDepth(inc); // note: doesn't need access to payload
|
||||
}
|
||||
this.incoming.sort(function(a, b) {
|
||||
if ((typeof(a.depth) == "number" && typeof(b.depth) == "undefined") ||
|
||||
@ -408,10 +409,10 @@ NewEngine.prototype = {
|
||||
(a.depth == null && typeof(b.depth) == "number") ||
|
||||
(a.depth < b.depth))
|
||||
return -1;
|
||||
//if (a.index > b.index)
|
||||
// return -1;
|
||||
//if (a.index < b.index)
|
||||
// return 1;
|
||||
if (a.cleartext.index > b.cleartext.index)
|
||||
return 1;
|
||||
if (a.cleartext.index < b.cleartext.index)
|
||||
return -1;
|
||||
return 0;
|
||||
});
|
||||
|
||||
|
@ -914,8 +914,6 @@ BookmarksStore.prototype = {
|
||||
if (!this._lookup)
|
||||
this.wrap();
|
||||
|
||||
yield record.decrypt(self.cb, ID.get('WeaveCryptoID').password);
|
||||
|
||||
this._log.trace("RECORD: " + record.id + " -> " + uneval(record.cleartext));
|
||||
|
||||
if (record.cleartext == "")
|
||||
@ -1071,16 +1069,17 @@ BookmarksStore.prototype = {
|
||||
if (command.GUID == "menu" ||
|
||||
command.GUID == "toolbar" ||
|
||||
command.GUID == "unfiled") {
|
||||
this._log.warn("Attempted to edit root node (" + command.GUID +
|
||||
"). Skipping command.");
|
||||
this._log.debug("Attempted to edit root node (" + command.GUID +
|
||||
"). Skipping command.");
|
||||
return;
|
||||
}
|
||||
|
||||
var itemId = this._bms.getItemIdForGUID(command.GUID);
|
||||
if (itemId < 0) {
|
||||
this._log.warn("Item for GUID " + command.GUID + " not found. Skipping.");
|
||||
this._log.debug("Item for GUID " + command.GUID + " not found. Skipping.");
|
||||
return;
|
||||
}
|
||||
this._log.trace("Editing item " + itemId);
|
||||
|
||||
for (let key in command.data) {
|
||||
switch (key) {
|
||||
@ -1103,15 +1102,29 @@ BookmarksStore.prototype = {
|
||||
this._bms.changeBookmarkURI(itemId, Utils.makeURI(command.data.URI));
|
||||
break;
|
||||
case "index":
|
||||
this._bms.moveItem(itemId, this._bms.getFolderIdForItem(itemId),
|
||||
command.data.index);
|
||||
let curIdx = this._bms.getItemIndex(itemId);
|
||||
if (curIdx != command.data.index) {
|
||||
// ignore index if we're going to move the item to another folder altogether
|
||||
if (command.data.parentGUID &&
|
||||
(this._bms.getFolderIdForItem(itemId) !=
|
||||
this._getItemIdForGUID(command.data.parentGUID)))
|
||||
break;
|
||||
this._log.trace("Moving item (changing index)");
|
||||
this._bms.moveItem(itemId, this._bms.getFolderIdForItem(itemId),
|
||||
command.data.index);
|
||||
}
|
||||
break;
|
||||
case "parentGUID": {
|
||||
let index = -1;
|
||||
if (command.data.index && command.data.index >= 0)
|
||||
index = command.data.index;
|
||||
this._bms.moveItem(
|
||||
itemId, this._getItemIdForGUID(command.data.parentGUID), index);
|
||||
if (command.data.parentGUID &&
|
||||
(this._bms.getFolderIdForItem(itemId) !=
|
||||
this._getItemIdForGUID(command.data.parentGUID))) {
|
||||
this._log.trace("Moving item (changing folder)");
|
||||
let index = -1;
|
||||
if (command.data.index && command.data.index >= 0)
|
||||
index = command.data.index;
|
||||
this._bms.moveItem(itemId,
|
||||
this._getItemIdForGUID(command.data.parentGUID), index);
|
||||
}
|
||||
} break;
|
||||
case "tags": {
|
||||
// filter out null/undefined/empty tags
|
||||
|
Loading…
Reference in New Issue
Block a user