Resolve conflicts one at a time
Previously, with a mix of text and media messages in conflict, asynchronous callbacks aligned so as to fail to remove some of the conflict objects on messages. Fix by serializing conflict processing, but making sure to move on through the message list even if some conflict resolutions fail. Fixes #370 // FREEBIE
This commit is contained in:
parent
4c4b875348
commit
9c8933c3d0
2 changed files with 7 additions and 6 deletions
|
@ -301,15 +301,16 @@
|
|||
|
||||
return textsecure.storage.axolotl.removeIdentityKey(number).then(function() {
|
||||
return textsecure.storage.axolotl.putIdentityKey(number, identityKey).then(function() {
|
||||
var promises = [];
|
||||
var promise = Promise.resolve();
|
||||
this.messageCollection.each(function(message) {
|
||||
if (message.hasKeyConflict(number)) {
|
||||
promises.push(new Promise(function(resolve) {
|
||||
resolve(message.resolveConflict(number));
|
||||
}));
|
||||
var resolveConflict = function() {
|
||||
return message.resolveConflict(number);
|
||||
};
|
||||
promise = promise.then(resolveConflict, resolveConflict);
|
||||
}
|
||||
});
|
||||
return promises;
|
||||
return promise;
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
},
|
||||
|
|
|
@ -199,7 +199,6 @@
|
|||
resolveConflict: function(number) {
|
||||
var error = this.getKeyConflict(number);
|
||||
if (error) {
|
||||
this.removeConflictFor(number);
|
||||
var promise = new textsecure.ReplayableError(error).replay();
|
||||
if (this.isIncoming()) {
|
||||
promise = promise.then(function(dataMessage) {
|
||||
|
@ -207,6 +206,7 @@
|
|||
}.bind(this));
|
||||
} else {
|
||||
promise = promise.then(function() {
|
||||
this.removeConflictFor(number);
|
||||
this.save();
|
||||
}.bind(this));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue