do not trigger closed group update on unchanged member list

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

@ -164,7 +164,6 @@
Component: window.Signal.Components.UpdateGroupMembersDialog,
props: {
titleText: this.titleText,
groupName: this.groupName,
okText: i18n('ok'),
cancelText: i18n('cancel'),
isPublic: this.isPublic,
@ -180,13 +179,24 @@
this.$el.append(this.dialogView.el);
return this;
},
onSubmit(groupName, newMembers) {
onSubmit(newMembers) {
const ourPK = textsecure.storage.user.getNumber();
const allMembers = window.Lodash.concat(newMembers, [ourPK]);
// 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 notPresentInNew = this.existingMembers.filter(m => !allMembers.includes(m));
// would be easer with _.xor but for some reason we do not have it
const xor = notPresentInNew.concat(notPresentInOld)
if (xor.length === 0) {
window.console.log('skipping group update: no detected changes in group member list');
return;
}
window.doUpdateGroup(
this.groupId,
groupName,
this.groupName,
allMembers,
this.avatarPath
);

@ -11,7 +11,6 @@ import {
interface Props {
titleText: string;
groupName: string;
okText: string;
isPublic: boolean;
cancelText: string;
@ -72,7 +71,7 @@ export class UpdateGroupMembersDialog extends React.Component<Props, State> {
d => d.id
);
this.props.onSubmit(this.props.groupName, members);
this.props.onSubmit(members);
this.closeDialog();
}

Loading…
Cancel
Save