mirror of
https://github.com/oxen-io/session-desktop.git
synced 2023-12-14 02:12:57 +01:00
call 'onFriendRequestSent' only after the message was successfully sent
This commit is contained in:
parent
5602f4bfff
commit
fb020f88ea
1 changed files with 12 additions and 3 deletions
|
@ -365,18 +365,22 @@ OutgoingMessage.prototype = {
|
|||
},
|
||||
|
||||
sendToNumber(number) {
|
||||
let conversation;
|
||||
try {
|
||||
conversation = ConversationController.get(number);
|
||||
} catch(e) {
|
||||
}
|
||||
|
||||
return this.getStaleDeviceIdsForNumber(number).then(updateDevices =>
|
||||
this.getKeysForNumber(number, updateDevices)
|
||||
.then(async (keysFound) => {
|
||||
const conversation = ConversationController.get(number);
|
||||
let attachPrekeys = false;
|
||||
if (!keysFound)
|
||||
{
|
||||
log.info("Fallback encryption enabled");
|
||||
conversation.onFriendRequestSent();
|
||||
this.fallBackEncryption = true;
|
||||
attachPrekeys = true;
|
||||
} else {
|
||||
} else if (conversation) {
|
||||
try {
|
||||
attachPrekeys = !conversation.isKeyExchangeCompleted();
|
||||
} catch(e) {
|
||||
|
@ -389,6 +393,11 @@ OutgoingMessage.prototype = {
|
|||
this.message.preKeyBundleMessage = await libloki.getPreKeyBundleForNumber(number);
|
||||
}
|
||||
}).then(this.reloadDevicesAndSend(number, true))
|
||||
.then(() => {
|
||||
if (this.fallBackEncryption && conversation) {
|
||||
conversation.onFriendRequestSent();
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
if (error.message === 'Identity key changed') {
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
|
|
Loading…
Reference in a new issue