Display incoming messages in the primary device conversation

pull/440/head
sachaaaaa 6 years ago
parent 5eab2098b6
commit 2c052a65a2

@ -1016,7 +1016,7 @@
ev.confirm();
}
function onTyping(ev) {
async function onTyping(ev) {
const { typing, sender, senderDevice } = ev;
const { groupId, started } = typing || {};
@ -1025,7 +1025,17 @@
return;
}
const conversation = ConversationController.get(groupId || sender);
let primaryDevice = null;
const authorisation = await window.libloki.storage.getGrantAuthorisationForSecondaryPubKey(
sender
);
if (authorisation) {
primaryDevice = authorisation.primaryDevicePubKey;
}
const conversation = ConversationController.get(
groupId || primaryDevice || sender
);
if (conversation) {
conversation.notifyTyping({
@ -1239,6 +1249,14 @@
const messageDescriptor = getMessageDescriptor(data);
// Funnel messages to primary device conversation if multi-device
const authorisation = await window.libloki.storage.getGrantAuthorisationForSecondaryPubKey(
messageDescriptor.id
);
if (authorisation) {
messageDescriptor.id = authorisation.primaryDevicePubKey;
}
const { PROFILE_KEY_UPDATE } = textsecure.protobuf.DataMessage.Flags;
// eslint-disable-next-line no-bitwise
const isProfileUpdate = Boolean(data.message.flags & PROFILE_KEY_UPDATE);

@ -3,7 +3,8 @@
Whisper,
ConversationController,
MessageController,
_
_,
libloki,
*/
/* eslint-disable more/no-then */
@ -34,6 +35,15 @@
if (messages.length === 0) {
return null;
}
const authorisation = await libloki.storage.getGrantAuthorisationForSecondaryPubKey(
source
);
if (authorisation) {
// eslint-disable-next-line no-param-reassign
source = authorisation.primaryDevicePubKey;
}
const message = messages.find(
item => !item.isIncoming() && source === item.get('conversationId')
);

@ -10,7 +10,8 @@
Signal,
textsecure,
Whisper,
clipboard
clipboard,
libloki,
*/
/* eslint-disable more/no-then */
@ -1697,7 +1698,7 @@
return message;
},
handleDataMessage(initialMessage, confirm) {
async handleDataMessage(initialMessage, confirm) {
// This function is called from the background script in a few scenarios:
// 1. on an incoming message
// 2. on a sent message sync'd from another device
@ -1707,9 +1708,15 @@
const source = message.get('source');
const type = message.get('type');
let conversationId = message.get('conversationId');
const authorisation = await libloki.storage.getGrantAuthorisationForSecondaryPubKey(
source
);
if (initialMessage.group) {
conversationId = initialMessage.group.id;
} else if (authorisation) {
conversationId = authorisation.primaryDevicePubKey;
}
const GROUP_TYPES = textsecure.protobuf.GroupContext.Type;
const conversation = ConversationController.get(conversationId);

Loading…
Cancel
Save