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, 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'); throw new Error('Group update is missing contacts');
} }
if (contacts.length === 1) { const otherPeopleNotifMsg =
if (contactsIncludesMe) { otherPeople.length === 1
return <Intl i18n={i18n} id="youJoinedTheGroup" />; ? 'joinedTheGroup'
} else { : 'multipleJoinedTheGroup';
return (
<Intl
i18n={i18n}
id="joinedTheGroup"
components={[otherPeopleWithCommas]}
/>
);
}
}
const joinedKey =
contacts.length > 1 ? 'multipleJoinedTheGroup' : 'joinedTheGroup';
return ( return (
<> <>
<Intl {otherPeople.length > 0 && (
i18n={i18n} <Intl
id={joinedKey} i18n={i18n}
components={[otherPeopleWithCommas]} id={otherPeopleNotifMsg}
/> components={[otherPeopleWithCommas]}
{contactsIncludesMe ? ( />
)}
{contactsIncludesMe && (
<div className="module-group-notification__change"> <div className="module-group-notification__change">
<Intl i18n={i18n} id="youJoinedTheGroup" /> <Intl i18n={i18n} id="youJoinedTheGroup" />
</div> </div>
) : null} )}
</> </>
); );
case 'remove': case 'remove':