From e1d06fc9be97b091e27ee0c234ad2f24b5a15244 Mon Sep 17 00:00:00 2001 From: Mikunj Varsani Date: Tue, 11 Feb 2020 09:09:58 +1100 Subject: [PATCH] Fix messages from secondary device not being mapped correctly to their primary device. Fix creating closed groups from secondary device. Fix primary device showing up in create group dialog. --- js/background.js | 9 +++++---- js/models/messages.js | 6 ++++++ ts/components/session/SessionClosableOverlay.tsx | 4 +++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/js/background.js b/js/background.js index 7ef8f8208..998ab0288 100644 --- a/js/background.js +++ b/js/background.js @@ -763,9 +763,10 @@ const ev = new Event('group'); - const ourKey = textsecure.storage.user.getNumber(); - - const allMembers = [ourKey, ...members]; + const primaryDeviceKey = + window.storage.get('primaryDevicePubKey') || + textsecure.storage.user.getNumber(); + const allMembers = [primaryDeviceKey, ...members]; ev.groupDetails = { id: groupId, @@ -794,7 +795,7 @@ window.friends.friendRequestStatusEnum.friends ); - convo.updateGroupAdmins([ourKey]); + convo.updateGroupAdmins([primaryDeviceKey]); appView.openConversation(groupId, {}); }; diff --git a/js/models/messages.js b/js/models/messages.js index 12339ac2b..03bd93642 100644 --- a/js/models/messages.js +++ b/js/models/messages.js @@ -2361,6 +2361,12 @@ await sendingDeviceConversation.onFriendRequestAccepted(); } } + + // We need to map the original message source to the primary device + if (source !== ourNumber) { + message.set({ source: primarySource }); + } + const id = await window.Signal.Data.saveMessage(message.attributes, { Message: Whisper.Message, }); diff --git a/ts/components/session/SessionClosableOverlay.tsx b/ts/components/session/SessionClosableOverlay.tsx index c9997e632..e632504fd 100644 --- a/ts/components/session/SessionClosableOverlay.tsx +++ b/ts/components/session/SessionClosableOverlay.tsx @@ -55,8 +55,10 @@ export class SessionClosableOverlay extends React.Component { const conversations = window.getConversations() || []; const conversationList = conversations.filter((conversation: any) => { + // TODO: We need to handle the case with > 1 secondary device + const isOurDevice = conversation.isMe() || conversation.isOurConversation(); return ( - !conversation.isOurConversation() && + !isOurDevice&& conversation.isPrivate() && !conversation.isSecondaryDevice() && conversation.isFriend()