diff --git a/js/models/conversations.js b/js/models/conversations.js index 55645adb8..9b012e74d 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -699,7 +699,7 @@ await this.sendVerifySyncMessage(this.id, verified); } }, - sendVerifySyncMessage(number, state) { + async sendVerifySyncMessage(number, state) { // Because syncVerification sends a (null) message to the target of the verify and // a sync message to our own devices, we need to send the accessKeys down for both // contacts. So we merge their sendOptions. @@ -709,12 +709,8 @@ ); const options = Object.assign({}, sendOptions, {}); - const promise = textsecure.storage.protocol.loadIdentityKey(number); - return promise.then(key => - this.wrapSend( - textsecure.messaging.syncVerification(number, state, key, options) - ) - ); + const key = await textsecure.storage.protocol.loadIdentityKey(number); + return textsecure.messaging.syncVerification(number, state, key, options); }, isVerified() { if (this.isPrivate()) { diff --git a/js/models/messages.js b/js/models/messages.js index a21668178..e66d95280 100644 --- a/js/models/messages.js +++ b/js/models/messages.js @@ -1447,9 +1447,9 @@ } }, - sendSyncMessage() { + async sendSyncMessage() { this.syncPromise = this.syncPromise || Promise.resolve(); - const next = () => { + const next = async () => { const encodedDataMessage = this.get('dataMessage'); if (this.get('synced') || !encodedDataMessage) { return Promise.resolve(); @@ -1470,18 +1470,17 @@ sentSyncMessageParams ); - return libsession + const result = await libsession .getMessageQueue() - .sendSyncMessage(sentSyncMessage) - .then(result => { - this.set({ - synced: true, - dataMessage: null, - }); - return window.Signal.Data.saveMessage(this.attributes, { - Message: Whisper.Message, - }).then(() => result); - }); + .sendSyncMessage(sentSyncMessage); + this.set({ + synced: true, + dataMessage: null, + }); + await window.Signal.Data.saveMessage(this.attributes, { + Message: Whisper.Message, + }); + return result; }; this.syncPromise = this.syncPromise.then(next, next);