Skip to content

Commit

Permalink
Merge pull request #859 from Bilb/various-group-updates-fixes
Browse files Browse the repository at this point in the history
Various group updates fixes
  • Loading branch information
vincentbavitz committed Feb 17, 2020
2 parents 39eb450 + b4f1afe commit fbf82ef
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 20 deletions.
32 changes: 29 additions & 3 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -2488,9 +2488,6 @@
"message": "Profile name cannot be empty",
"description": "Error message displayed on empty profile name"
},
"maxGroupMembersError": {
"message": "Max number of members for small group chats is: "
},
"nonAdminDeleteMember": {
"message": "Only group admin can remove members!"
},
Expand Down Expand Up @@ -2799,5 +2796,34 @@
},
"devicePairedSuccessfully": {
"message": "Device linked successfully"
},
"invalidGroupName": {
"message": "Group Name length must be between 1 to $maxSize$",
"description": "Error message displayed on invalid group name",
"placeholders": {
"maxSize": {
"content": "$1",
"example": "125"
}
}
},
"invalidGroupSize": {
"message": "Closed Group size must be between 1 to $maxSize$",
"description": "Error message displayed on invalid closed group size",
"placeholders": {
"maxSize": {
"content": "$1",
"example": "10"
}
}
},
"maxGroupMembersError": {
"message": "Max number of members for small group chats is $maxSize$",
"placeholders": {
"maxSize": {
"content": "$1",
"example": "10"
}
}
}
}
6 changes: 2 additions & 4 deletions js/views/invite_friends_dialog_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,9 @@
// Do not trigger an update if there is too many members
if (
newMembers.length + existingMembers.length >
window.SMALL_GROUP_SIZE_LIMIT
window.CONSTANTS.SMALL_GROUP_SIZE_LIMIT
) {
const msg = `${window.i18n('maxGroupMembersError')} ${
window.SMALL_GROUP_SIZE_LIMIT
}`;
const msg = window.i18n('maxGroupMembersError', window.CONSTANTS.SMALL_GROUP_SIZE_LIMIT);

window.pushToast({
title: msg,
Expand Down
11 changes: 0 additions & 11 deletions ts/components/conversation/UpdateGroupMembersDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,17 +202,6 @@ export class UpdateGroupMembersDialog extends React.Component<Props, State> {
}
});

const newMemberCount = this.getMemberCount(updatedFriends);

if (newMemberCount > window.CONSTANTS.SMALL_GROUP_SIZE_LIMIT) {
const msg = `${this.props.i18n('maxGroupMembersError')} ${
window.CONSTANTS.SMALL_GROUP_SIZE_LIMIT
}`;
this.onShowError(msg);

return;
}

this.setState(state => {
return {
...state,
Expand Down
21 changes: 19 additions & 2 deletions ts/components/session/LeftPaneChannelSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -399,11 +399,28 @@ export class LeftPaneChannelSection extends React.Component<Props, State> {
groupMembers: Array<ContactType>
) {
// Validate groupName and groupMembers length
if (groupName.length === 0 ||
groupName.length > window.CONSTANTS.MAX_GROUP_NAME_LENGTH) {
window.pushToast({
title: window.i18n('invalidGroupName', window.CONSTANTS.MAX_GROUP_NAME_LENGTH),
type: 'error',
id: 'invalidGroupName',
});

return;
}

// >= because we add ourself as a member after this. so a 10 group is already invalid as it will be 11 with ourself
if (
groupMembers.length === 0 ||
groupName.length === 0 ||
groupName.length > window.CONSTANTS.MAX_GROUP_NAME_LENGTH
groupMembers.length >= window.CONSTANTS.SMALL_GROUP_SIZE_LIMIT
) {
window.pushToast({
title: window.i18n('invalidGroupSize', window.CONSTANTS.SMALL_GROUP_SIZE_LIMIT),
type: 'error',
id: 'invalidGroupSize',
});

return;
}

Expand Down

0 comments on commit fbf82ef

Please sign in to comment.