diff --git a/js/models/conversations.js b/js/models/conversations.js index 9d75325d1..c0e3aff9b 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -111,13 +111,13 @@ }.bind(this)).then(function() { this.addVerifiedChange(this.id, verified === VERIFIED, {local: !options.viaSyncMessage}); if (!options.viaSyncMessage) { - this.sendVerifySyncMessage(this.id, verified); + return this.sendVerifySyncMessage(this.id, verified); } }.bind(this)); }, sendVerifySyncMessage: function(number, state) { textsecure.storage.protocol.loadIdentityKey(number).then(function(key) { - textsecure.messaging.syncVerification(number, state, key); + return textsecure.messaging.syncVerification(number, state, key); }); }, isVerified: function() { diff --git a/js/signal_protocol_store.js b/js/signal_protocol_store.js index c987022ab..c0050a69c 100644 --- a/js/signal_protocol_store.js +++ b/js/signal_protocol_store.js @@ -606,17 +606,20 @@ || (isPresent && !isEqual) || (isPresent && identityRecord.get('verified') !== VerifiedStatus.VERIFIED))) { - if (!isPresent || !isEqual) { - this.trigger('keychange', identifier); - } - textsecure.storage.protocol.saveIdentityWithAttributes(identifier, { publicKey : publicKey, verified : verifiedStatus, firstUse : false, timestamp : Date.now(), nonblockingApproval : true - }).then(resolve, reject); + }).then(function() { + if (!isPresent || !isEqual) { + this.trigger('keychange', identifier); + return this.archiveAllSessions(identifier).then(resolve, reject); + } + + return resolve(); + }.bind(this), reject); } }.bind(this)); }.bind(this));