From cc8277f54d15568b6ce7308192247d73ed0c6513 Mon Sep 17 00:00:00 2001 From: Beaudan Brown Date: Tue, 29 Oct 2019 13:41:36 +1100 Subject: [PATCH] Better variable name and use it in more places --- js/models/messages.js | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/js/models/messages.js b/js/models/messages.js index e458dcce9..7c88423d9 100644 --- a/js/models/messages.js +++ b/js/models/messages.js @@ -1958,6 +1958,10 @@ }); } + const sendingDeviceConversation = await ConversationController.getOrCreateAndWait( + source, + 'private' + ); if (dataMessage.profileKey) { const profileKey = dataMessage.profileKey.toString('base64'); if (source === textsecure.storage.user.getNumber()) { @@ -1965,25 +1969,13 @@ } else if (conversation.isPrivate()) { conversation.setProfileKey(profileKey); } else { - ConversationController.getOrCreateAndWait(source, 'private').then( - sender => { - sender.setProfileKey(profileKey); - } - ); + sendingDeviceConversation.setProfileKey(profileKey); } } else if (dataMessage.profile) { - ConversationController.getOrCreateAndWait(source, 'private').then( - sender => { - sender.setLokiProfile(dataMessage.profile); - } - ); + sendingDeviceConversation.setLokiProfile(dataMessage.profile); } let autoAccept = false; - const requestConversation = await ConversationController.getOrCreateAndWait( - source, - 'private' - ); if (message.get('type') === 'friend-request') { /* Here is the before and after state diagram for the operation before. @@ -2000,16 +1992,16 @@ - We are friends with the user, and that user just sent us a friend request. */ if ( - requestConversation.hasSentFriendRequest() || - requestConversation.isFriend() + sendingDeviceConversation.hasSentFriendRequest() || + sendingDeviceConversation.isFriend() ) { // Automatically accept incoming friend requests if we have send one already autoAccept = true; message.set({ friendStatus: 'accepted' }); - await requestConversation.onFriendRequestAccepted(); + await sendingDeviceConversation.onFriendRequestAccepted(); window.libloki.api.sendBackgroundMessage(message.get('source')); } else { - await requestConversation.onFriendRequestReceived(); + await sendingDeviceConversation.onFriendRequestReceived(); } } else { await conversation.onFriendRequestAccepted();