Better variable name and use it in more places

pull/586/head
Beaudan Brown 6 years ago
parent 883feb668d
commit cc8277f54d

@ -1958,6 +1958,10 @@
}); });
} }
const sendingDeviceConversation = await ConversationController.getOrCreateAndWait(
source,
'private'
);
if (dataMessage.profileKey) { if (dataMessage.profileKey) {
const profileKey = dataMessage.profileKey.toString('base64'); const profileKey = dataMessage.profileKey.toString('base64');
if (source === textsecure.storage.user.getNumber()) { if (source === textsecure.storage.user.getNumber()) {
@ -1965,25 +1969,13 @@
} else if (conversation.isPrivate()) { } else if (conversation.isPrivate()) {
conversation.setProfileKey(profileKey); conversation.setProfileKey(profileKey);
} else { } else {
ConversationController.getOrCreateAndWait(source, 'private').then( sendingDeviceConversation.setProfileKey(profileKey);
sender => {
sender.setProfileKey(profileKey);
}
);
} }
} else if (dataMessage.profile) { } else if (dataMessage.profile) {
ConversationController.getOrCreateAndWait(source, 'private').then( sendingDeviceConversation.setLokiProfile(dataMessage.profile);
sender => {
sender.setLokiProfile(dataMessage.profile);
}
);
} }
let autoAccept = false; let autoAccept = false;
const requestConversation = await ConversationController.getOrCreateAndWait(
source,
'private'
);
if (message.get('type') === 'friend-request') { if (message.get('type') === 'friend-request') {
/* /*
Here is the before and after state diagram for the operation before. 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. - We are friends with the user, and that user just sent us a friend request.
*/ */
if ( if (
requestConversation.hasSentFriendRequest() || sendingDeviceConversation.hasSentFriendRequest() ||
requestConversation.isFriend() sendingDeviceConversation.isFriend()
) { ) {
// Automatically accept incoming friend requests if we have send one already // Automatically accept incoming friend requests if we have send one already
autoAccept = true; autoAccept = true;
message.set({ friendStatus: 'accepted' }); message.set({ friendStatus: 'accepted' });
await requestConversation.onFriendRequestAccepted(); await sendingDeviceConversation.onFriendRequestAccepted();
window.libloki.api.sendBackgroundMessage(message.get('source')); window.libloki.api.sendBackgroundMessage(message.get('source'));
} else { } else {
await requestConversation.onFriendRequestReceived(); await sendingDeviceConversation.onFriendRequestReceived();
} }
} else { } else {
await conversation.onFriendRequestAccepted(); await conversation.onFriendRequestAccepted();

Loading…
Cancel
Save