fix display name and avatar not being updated when message from secondary

pull/1223/head
Audric Ackermann 5 years ago
parent ed48818867
commit 15b8600e25
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -644,8 +644,6 @@
confirm: () => {}, confirm: () => {},
}; };
const recipients = _.union(convo.get('members'), members); const recipients = _.union(convo.get('members'), members);
await window.NewReceiver.onGroupReceived(ev); await window.NewReceiver.onGroupReceived(ev);

@ -70,12 +70,20 @@ export async function updateProfile(
newProfile.avatar = null; newProfile.avatar = null;
} }
await conversation.setLokiProfile(newProfile); const allUserDevices = await MultiDeviceProtocol.getAllDevices(
conversation.id
if (conversation.isSecondaryDevice()) { );
const primaryConversation = await conversation.getPrimaryConversation(); const { ConversationController } = window;
await primaryConversation.setLokiProfile(newProfile);
} await Promise.all(
allUserDevices.map(async device => {
const conv = await ConversationController.getOrCreateAndWait(
device.key,
'private'
);
await conv.setLokiProfile(newProfile);
})
);
} }
function cleanAttachment(attachment: any) { function cleanAttachment(attachment: any) {

@ -13,18 +13,15 @@ async function handleGroups(
group: any, group: any,
source: any source: any
): Promise<any> { ): Promise<any> {
const textsecure = window.textsecure;
const GROUP_TYPES = SignalService.GroupContext.Type; const GROUP_TYPES = SignalService.GroupContext.Type;
// TODO: this should be primary device id!
const ourNumber = textsecure.storage.user.getNumber();
let groupUpdate = null; let groupUpdate = null;
// conversation attributes // conversation attributes
const attributes: any = { const attributes: any = {
type: 'group', type: 'group',
groupId: group.id, groupId: group.id,
...conversation.attributes,
}; };
const oldMembers = conversation.get('members'); const oldMembers = conversation.get('members');
@ -54,15 +51,21 @@ async function handleGroups(
// Check if anyone got kicked: // Check if anyone got kicked:
const removedMembers = _.difference(oldMembers, attributes.members); const removedMembers = _.difference(oldMembers, attributes.members);
const isOurDeviceMap = await Promise.all(
removedMembers.map(async member =>
MultiDeviceProtocol.isOurDevice(member)
)
);
const ourDeviceWasRemoved = isOurDeviceMap.includes(true);
if (removedMembers.includes(ourNumber)) { if (ourDeviceWasRemoved) {
groupUpdate.kicked = 'You'; groupUpdate.kicked = 'You';
attributes.isKickedFromGroup = true; attributes.isKickedFromGroup = true;
} else if (removedMembers.length) { } else if (removedMembers.length) {
groupUpdate.kicked = removedMembers; groupUpdate.kicked = removedMembers;
} }
} else if (group.type === GROUP_TYPES.QUIT) { } else if (group.type === GROUP_TYPES.QUIT) {
if (source === ourNumber) { if (await MultiDeviceProtocol.isOurDevice(source)) {
attributes.left = true; attributes.left = true;
groupUpdate = { left: 'You' }; groupUpdate = { left: 'You' };
} else { } else {

@ -105,8 +105,6 @@ export class SessionProtocol {
public static async sendSessionRequestIfNeeded( public static async sendSessionRequestIfNeeded(
pubkey: PubKey pubkey: PubKey
): Promise<void> { ): Promise<void> {
const { ConversationController } = window;
if ( if (
(await SessionProtocol.hasSession(pubkey)) || (await SessionProtocol.hasSession(pubkey)) ||
(await SessionProtocol.hasSentSessionRequest(pubkey)) (await SessionProtocol.hasSentSessionRequest(pubkey))

Loading…
Cancel
Save