GroupNotification: Fix 'joined group' pluralization (#4380)

This commit is contained in:
Jan Janik 2020-06-26 00:36:24 +02:00 committed by GitHub
parent 4a83adfad6
commit fd6358ac9d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 23 deletions

View file

@ -179,6 +179,29 @@ const stories: Array<GroupNotificationStory> = [
],
i18n,
},
{
from: {
name: 'Alice',
phoneNumber: '(202) 555-1000',
},
changes: [
{
type: 'add',
contacts: [
{
phoneNumber: '(202) 555-1000',
profileName: 'Mr. Fire',
isMe: true,
},
{
phoneNumber: '(202) 555-1001',
profileName: 'Mrs. Ice',
},
],
},
],
i18n,
},
],
],
[

View file

@ -75,35 +75,25 @@ export class GroupNotification extends React.Component<Props> {
throw new Error('Group update is missing contacts');
}
if (contacts.length === 1) {
if (contactsIncludesMe) {
return <Intl i18n={i18n} id="youJoinedTheGroup" />;
} else {
return (
<Intl
i18n={i18n}
id="joinedTheGroup"
components={[otherPeopleWithCommas]}
/>
);
}
}
const joinedKey =
contacts.length > 1 ? 'multipleJoinedTheGroup' : 'joinedTheGroup';
const otherPeopleNotifMsg =
otherPeople.length === 1
? 'joinedTheGroup'
: 'multipleJoinedTheGroup';
return (
<>
<Intl
i18n={i18n}
id={joinedKey}
components={[otherPeopleWithCommas]}
/>
{contactsIncludesMe ? (
{otherPeople.length > 0 && (
<Intl
i18n={i18n}
id={otherPeopleNotifMsg}
components={[otherPeopleWithCommas]}
/>
)}
{contactsIncludesMe && (
<div className="module-group-notification__change">
<Intl i18n={i18n} id="youJoinedTheGroup" />
</div>
) : null}
)}
</>
);
case 'remove':