fix group update notifcation when we are added to the group

pull/1093/head
Audric Ackermann 6 years ago
parent b60188331a
commit 3c2746d910
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -205,6 +205,9 @@
}, },
getLokiNameForNumber(number) { getLokiNameForNumber(number) {
const conversation = ConversationController.get(number); const conversation = ConversationController.get(number);
if (number === textsecure.storage.user.getNumber()) {
return i18n('you');
}
if (!conversation || !conversation.getLokiProfile()) { if (!conversation || !conversation.getLokiProfile()) {
return number; return number;
} }
@ -501,6 +504,12 @@
const contactModel = this.findContact(phoneNumber); const contactModel = this.findContact(phoneNumber);
const color = contactModel ? contactModel.getColor() : null; const color = contactModel ? contactModel.getColor() : null;
let profileName;
if (phoneNumber === window.storage.get('primaryDevicePubKey')) {
profileName = i18n('you');
} else {
profileName = contactModel ? contactModel.getProfileName() : null;
}
return { return {
phoneNumber: format(phoneNumber, { phoneNumber: format(phoneNumber, {
@ -509,7 +518,7 @@
color, color,
avatarPath: contactModel ? contactModel.getAvatarPath() : null, avatarPath: contactModel ? contactModel.getAvatarPath() : null,
name: contactModel ? contactModel.getName() : null, name: contactModel ? contactModel.getName() : null,
profileName: contactModel ? contactModel.getProfileName() : null, profileName,
title: contactModel ? contactModel.getTitle() : null, title: contactModel ? contactModel.getTitle() : null,
}; };
}, },

@ -184,12 +184,18 @@
const allMembers = window.Lodash.concat(newMembers, [ourPK]); const allMembers = window.Lodash.concat(newMembers, [ourPK]);
// We need to NOT trigger an group update if the list of member is the same. // We need to NOT trigger an group update if the list of member is the same.
const notPresentInOld = allMembers.filter(m => !this.existingMembers.includes(m)); const notPresentInOld = allMembers.filter(
const notPresentInNew = this.existingMembers.filter(m => !allMembers.includes(m)); m => !this.existingMembers.includes(m)
);
const notPresentInNew = this.existingMembers.filter(
m => !allMembers.includes(m)
);
// would be easer with _.xor but for some reason we do not have it // would be easer with _.xor but for some reason we do not have it
const xor = notPresentInNew.concat(notPresentInOld) const xor = notPresentInNew.concat(notPresentInOld);
if (xor.length === 0) { if (xor.length === 0) {
window.console.log('skipping group update: no detected changes in group member list'); window.console.log(
'skipping group update: no detected changes in group member list'
);
return; return;
} }

@ -1,5 +1,4 @@
import React from 'react'; import React from 'react';
// import classNames from 'classnames';
import { compact, flatten } from 'lodash'; import { compact, flatten } from 'lodash';
import { Intl } from '../Intl'; import { Intl } from '../Intl';
@ -25,6 +24,8 @@ interface Props {
i18n: LocalizerType; i18n: LocalizerType;
} }
// This class is used to display group updates in the conversation view.
// This is a not a "notification" as the name suggests, but a message inside the conversation
export class GroupNotification extends React.Component<Props> { export class GroupNotification extends React.Component<Props> {
public renderChange(change: Change) { public renderChange(change: Change) {
const { isMe, contacts, type, newName } = change; const { isMe, contacts, type, newName } = change;

Loading…
Cancel
Save