Group call started notification use address book name
This commit is contained in:
parent
d7b09b9703
commit
342373bdfe
3 changed files with 22 additions and 25 deletions
|
@ -9,6 +9,7 @@ import enMessages from '../../../_locales/en/messages.json';
|
||||||
import { CallMode } from '../../types/Calling';
|
import { CallMode } from '../../types/Calling';
|
||||||
import { CallingNotification } from './CallingNotification';
|
import { CallingNotification } from './CallingNotification';
|
||||||
import type { CallingNotificationType } from '../../util/callingNotification';
|
import type { CallingNotificationType } from '../../util/callingNotification';
|
||||||
|
import { getDefaultConversation } from '../../test-both/helpers/getDefaultConversation';
|
||||||
|
|
||||||
const i18n = setupI18n('en', enMessages);
|
const i18n = setupI18n('en', enMessages);
|
||||||
|
|
||||||
|
@ -235,7 +236,7 @@ export function GroupCallByYou(): JSX.Element {
|
||||||
<CallingNotification
|
<CallingNotification
|
||||||
{...getCommonProps()}
|
{...getCommonProps()}
|
||||||
callMode={CallMode.Group}
|
callMode={CallMode.Group}
|
||||||
creator={{ isMe: true, title: 'Alicia' }}
|
creator={getDefaultConversation({ isMe: true, title: 'Alicia' })}
|
||||||
deviceCount={15}
|
deviceCount={15}
|
||||||
ended={false}
|
ended={false}
|
||||||
maxDevices={16}
|
maxDevices={16}
|
||||||
|
@ -249,7 +250,7 @@ export function GroupCallBySomeone(): JSX.Element {
|
||||||
<CallingNotification
|
<CallingNotification
|
||||||
{...getCommonProps()}
|
{...getCommonProps()}
|
||||||
callMode={CallMode.Group}
|
callMode={CallMode.Group}
|
||||||
creator={{ isMe: false, title: 'Alicia' }}
|
creator={getDefaultConversation({ isMe: false, title: 'Alicia' })}
|
||||||
deviceCount={15}
|
deviceCount={15}
|
||||||
ended={false}
|
ended={false}
|
||||||
maxDevices={16}
|
maxDevices={16}
|
||||||
|
@ -265,10 +266,9 @@ export function GroupCallStartedBySomeoneWithALongName(): JSX.Element {
|
||||||
<CallingNotification
|
<CallingNotification
|
||||||
{...getCommonProps()}
|
{...getCommonProps()}
|
||||||
callMode={CallMode.Group}
|
callMode={CallMode.Group}
|
||||||
creator={{
|
creator={getDefaultConversation({
|
||||||
isMe: false,
|
|
||||||
title: longName,
|
title: longName,
|
||||||
}}
|
})}
|
||||||
deviceCount={15}
|
deviceCount={15}
|
||||||
ended={false}
|
ended={false}
|
||||||
maxDevices={16}
|
maxDevices={16}
|
||||||
|
|
|
@ -6,6 +6,7 @@ import { getCallingNotificationText } from '../../util/callingNotification';
|
||||||
import { CallMode } from '../../types/Calling';
|
import { CallMode } from '../../types/Calling';
|
||||||
import { setupI18n } from '../../util/setupI18n';
|
import { setupI18n } from '../../util/setupI18n';
|
||||||
import enMessages from '../../../_locales/en/messages.json';
|
import enMessages from '../../../_locales/en/messages.json';
|
||||||
|
import { getDefaultConversation } from '../helpers/getDefaultConversation';
|
||||||
|
|
||||||
describe('calling notification helpers', () => {
|
describe('calling notification helpers', () => {
|
||||||
const i18n = setupI18n('en', enMessages);
|
const i18n = setupI18n('en', enMessages);
|
||||||
|
@ -31,16 +32,15 @@ describe('calling notification helpers', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("includes the creator's first name when describing a call", () => {
|
it("includes the creator's first name when describing a call", () => {
|
||||||
|
const conversation = getDefaultConversation({
|
||||||
|
systemGivenName: 'Luigi',
|
||||||
|
});
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
getCallingNotificationText(
|
getCallingNotificationText(
|
||||||
{
|
{
|
||||||
callMode: CallMode.Group,
|
callMode: CallMode.Group,
|
||||||
conversationId: 'abc123',
|
conversationId: 'abc123',
|
||||||
creator: {
|
creator: conversation,
|
||||||
firstName: 'Luigi',
|
|
||||||
isMe: false,
|
|
||||||
title: 'Luigi Mario',
|
|
||||||
},
|
|
||||||
ended: false,
|
ended: false,
|
||||||
deviceCount: 1,
|
deviceCount: 1,
|
||||||
maxDevices: 23,
|
maxDevices: 23,
|
||||||
|
@ -53,15 +53,16 @@ describe('calling notification helpers', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("if the creator doesn't have a first name, falls back to their title", () => {
|
it("if the creator doesn't have a first name, falls back to their title", () => {
|
||||||
|
const conversation = getDefaultConversation({
|
||||||
|
systemGivenName: undefined,
|
||||||
|
title: 'Luigi Mario',
|
||||||
|
});
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
getCallingNotificationText(
|
getCallingNotificationText(
|
||||||
{
|
{
|
||||||
callMode: CallMode.Group,
|
callMode: CallMode.Group,
|
||||||
conversationId: 'abc123',
|
conversationId: 'abc123',
|
||||||
creator: {
|
creator: conversation,
|
||||||
isMe: false,
|
|
||||||
title: 'Luigi Mario',
|
|
||||||
},
|
|
||||||
ended: false,
|
ended: false,
|
||||||
deviceCount: 1,
|
deviceCount: 1,
|
||||||
maxDevices: 23,
|
maxDevices: 23,
|
||||||
|
@ -74,16 +75,15 @@ describe('calling notification helpers', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('has a special message if you were the one to start the call', () => {
|
it('has a special message if you were the one to start the call', () => {
|
||||||
|
const conversation = getDefaultConversation({
|
||||||
|
isMe: true,
|
||||||
|
});
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
getCallingNotificationText(
|
getCallingNotificationText(
|
||||||
{
|
{
|
||||||
callMode: CallMode.Group,
|
callMode: CallMode.Group,
|
||||||
conversationId: 'abc123',
|
conversationId: 'abc123',
|
||||||
creator: {
|
creator: conversation,
|
||||||
firstName: 'ShouldBeIgnored',
|
|
||||||
isMe: true,
|
|
||||||
title: 'ShouldBeIgnored Smith',
|
|
||||||
},
|
|
||||||
ended: false,
|
ended: false,
|
||||||
deviceCount: 1,
|
deviceCount: 1,
|
||||||
maxDevices: 23,
|
maxDevices: 23,
|
||||||
|
|
|
@ -5,6 +5,7 @@ import type { LocalizerType } from '../types/Util';
|
||||||
import { CallMode } from '../types/Calling';
|
import { CallMode } from '../types/Calling';
|
||||||
import { missingCaseError } from './missingCaseError';
|
import { missingCaseError } from './missingCaseError';
|
||||||
import * as log from '../logging/log';
|
import * as log from '../logging/log';
|
||||||
|
import type { ConversationType } from '../state/ducks/conversations';
|
||||||
|
|
||||||
type DirectCallNotificationType = {
|
type DirectCallNotificationType = {
|
||||||
callMode: CallMode.Direct;
|
callMode: CallMode.Direct;
|
||||||
|
@ -20,11 +21,7 @@ type GroupCallNotificationType = {
|
||||||
activeCallConversationId?: string;
|
activeCallConversationId?: string;
|
||||||
callMode: CallMode.Group;
|
callMode: CallMode.Group;
|
||||||
conversationId: string;
|
conversationId: string;
|
||||||
creator?: {
|
creator?: ConversationType;
|
||||||
firstName?: string;
|
|
||||||
isMe?: boolean;
|
|
||||||
title: string;
|
|
||||||
};
|
|
||||||
ended: boolean;
|
ended: boolean;
|
||||||
deviceCount: number;
|
deviceCount: number;
|
||||||
maxDevices: number;
|
maxDevices: number;
|
||||||
|
@ -90,7 +87,7 @@ function getGroupCallNotificationText(
|
||||||
return i18n('calling__call-notification__started-by-you');
|
return i18n('calling__call-notification__started-by-you');
|
||||||
}
|
}
|
||||||
return i18n('calling__call-notification__started', [
|
return i18n('calling__call-notification__started', [
|
||||||
notification.creator.firstName || notification.creator.title,
|
notification.creator.systemGivenName ?? notification.creator.title,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue