Use system nickname or first name for incoming group calls
Co-authored-by: ayumi-signal <143036029+ayumi-signal@users.noreply.github.com>
This commit is contained in:
parent
59cf4adf2c
commit
2588270466
5 changed files with 73 additions and 9 deletions
|
@ -39,11 +39,18 @@ export type PropsType = {
|
||||||
| 'phoneNumber'
|
| 'phoneNumber'
|
||||||
| 'profileName'
|
| 'profileName'
|
||||||
| 'sharedGroupNames'
|
| 'sharedGroupNames'
|
||||||
|
| 'systemGivenName'
|
||||||
|
| 'systemNickname'
|
||||||
| 'title'
|
| 'title'
|
||||||
| 'type'
|
| 'type'
|
||||||
| 'unblurredAvatarPath'
|
| 'unblurredAvatarPath'
|
||||||
>;
|
>;
|
||||||
groupMembers?: Array<Pick<ConversationType, 'id' | 'firstName' | 'title'>>;
|
groupMembers?: Array<
|
||||||
|
Pick<
|
||||||
|
ConversationType,
|
||||||
|
'id' | 'firstName' | 'systemGivenName' | 'systemNickname' | 'title'
|
||||||
|
>
|
||||||
|
>;
|
||||||
hasLocalAudio: boolean;
|
hasLocalAudio: boolean;
|
||||||
hasLocalVideo: boolean;
|
hasLocalVideo: boolean;
|
||||||
i18n: LocalizerType;
|
i18n: LocalizerType;
|
||||||
|
|
|
@ -25,6 +25,8 @@ export type PropsType = {
|
||||||
| 'phoneNumber'
|
| 'phoneNumber'
|
||||||
| 'profileName'
|
| 'profileName'
|
||||||
| 'sharedGroupNames'
|
| 'sharedGroupNames'
|
||||||
|
| 'systemGivenName'
|
||||||
|
| 'systemNickname'
|
||||||
| 'title'
|
| 'title'
|
||||||
| 'type'
|
| 'type'
|
||||||
| 'unblurredAvatarPath'
|
| 'unblurredAvatarPath'
|
||||||
|
@ -34,10 +36,18 @@ export type PropsType = {
|
||||||
ringMode: RingMode;
|
ringMode: RingMode;
|
||||||
|
|
||||||
// The following should only be set for group conversations.
|
// The following should only be set for group conversations.
|
||||||
groupMembers?: Array<Pick<ConversationType, 'id' | 'firstName' | 'title'>>;
|
groupMembers?: Array<
|
||||||
|
Pick<
|
||||||
|
ConversationType,
|
||||||
|
'id' | 'firstName' | 'systemGivenName' | 'systemNickname' | 'title'
|
||||||
|
>
|
||||||
|
>;
|
||||||
isCallFull?: boolean;
|
isCallFull?: boolean;
|
||||||
peekedParticipants?: Array<
|
peekedParticipants?: Array<
|
||||||
Pick<ConversationType, 'firstName' | 'title' | 'serviceId'>
|
Pick<
|
||||||
|
ConversationType,
|
||||||
|
'firstName' | 'systemGivenName' | 'systemNickname' | 'title' | 'serviceId'
|
||||||
|
>
|
||||||
>;
|
>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -53,8 +53,16 @@ export type PropsType = {
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
callMode: CallMode.Group;
|
callMode: CallMode.Group;
|
||||||
otherMembersRung: Array<Pick<ConversationType, 'firstName' | 'title'>>;
|
otherMembersRung: Array<
|
||||||
ringer: Pick<ConversationType, 'firstName' | 'title'>;
|
Pick<
|
||||||
|
ConversationType,
|
||||||
|
'firstName' | 'systemGivenName' | 'systemNickname' | 'title'
|
||||||
|
>
|
||||||
|
>;
|
||||||
|
ringer: Pick<
|
||||||
|
ConversationType,
|
||||||
|
'firstName' | 'systemGivenName' | 'systemNickname' | 'title'
|
||||||
|
>;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -96,8 +104,16 @@ function GroupCallMessage({
|
||||||
ringer,
|
ringer,
|
||||||
}: Readonly<{
|
}: Readonly<{
|
||||||
i18n: LocalizerType;
|
i18n: LocalizerType;
|
||||||
otherMembersRung: Array<Pick<ConversationType, 'firstName' | 'title'>>;
|
otherMembersRung: Array<
|
||||||
ringer: Pick<ConversationType, 'firstName' | 'title'>;
|
Pick<
|
||||||
|
ConversationType,
|
||||||
|
'firstName' | 'systemGivenName' | 'systemNickname' | 'title'
|
||||||
|
>
|
||||||
|
>;
|
||||||
|
ringer: Pick<
|
||||||
|
ConversationType,
|
||||||
|
'firstName' | 'systemGivenName' | 'systemNickname' | 'title'
|
||||||
|
>;
|
||||||
}>): JSX.Element {
|
}>): JSX.Element {
|
||||||
// As an optimization, we only process the first two names.
|
// As an optimization, we only process the first two names.
|
||||||
const [first, second] = otherMembersRung
|
const [first, second] = otherMembersRung
|
||||||
|
|
|
@ -20,4 +20,25 @@ describe('getParticipantName', () => {
|
||||||
|
|
||||||
assert.strictEqual(getParticipantName(participant), 'Foo Bar');
|
assert.strictEqual(getParticipantName(participant), 'Foo Bar');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('returns system given name if available', () => {
|
||||||
|
const participant = {
|
||||||
|
firstName: 'Foo',
|
||||||
|
systemGivenName: 'Foo from that party',
|
||||||
|
title: 'Foo Bar',
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.strictEqual(getParticipantName(participant), 'Foo from that party');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns system nickname if available', () => {
|
||||||
|
const participant = {
|
||||||
|
firstName: 'Foo',
|
||||||
|
systemGivenName: 'Foo from that party',
|
||||||
|
systemNickname: 'Foo-chan',
|
||||||
|
title: 'Foo Bar',
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.strictEqual(getParticipantName(participant), 'Foo-chan');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,7 +4,17 @@
|
||||||
import type { ConversationType } from '../state/ducks/conversations';
|
import type { ConversationType } from '../state/ducks/conversations';
|
||||||
|
|
||||||
export function getParticipantName(
|
export function getParticipantName(
|
||||||
participant: Readonly<Pick<ConversationType, 'firstName' | 'title'>>
|
participant: Readonly<
|
||||||
|
Pick<
|
||||||
|
ConversationType,
|
||||||
|
'firstName' | 'systemGivenName' | 'systemNickname' | 'title'
|
||||||
|
>
|
||||||
|
>
|
||||||
): string {
|
): string {
|
||||||
return participant.firstName || participant.title;
|
return (
|
||||||
|
participant.systemNickname ||
|
||||||
|
participant.systemGivenName ||
|
||||||
|
participant.firstName ||
|
||||||
|
participant.title
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue