From 342373bdfee3c4b712992c87b81526213694873a Mon Sep 17 00:00:00 2001 From: Jamie Kyle <113370520+jamiebuilds-signal@users.noreply.github.com> Date: Thu, 12 Jan 2023 15:29:07 -0800 Subject: [PATCH] Group call started notification use address book name --- .../CallingNotification.stories.tsx | 10 +++---- ts/test-both/util/callingNotification_test.ts | 28 +++++++++---------- ts/util/callingNotification.ts | 9 ++---- 3 files changed, 22 insertions(+), 25 deletions(-) diff --git a/ts/components/conversation/CallingNotification.stories.tsx b/ts/components/conversation/CallingNotification.stories.tsx index 865218b6ae..9619bb6345 100644 --- a/ts/components/conversation/CallingNotification.stories.tsx +++ b/ts/components/conversation/CallingNotification.stories.tsx @@ -9,6 +9,7 @@ import enMessages from '../../../_locales/en/messages.json'; import { CallMode } from '../../types/Calling'; import { CallingNotification } from './CallingNotification'; import type { CallingNotificationType } from '../../util/callingNotification'; +import { getDefaultConversation } from '../../test-both/helpers/getDefaultConversation'; const i18n = setupI18n('en', enMessages); @@ -235,7 +236,7 @@ export function GroupCallByYou(): JSX.Element { { const i18n = setupI18n('en', enMessages); @@ -31,16 +32,15 @@ describe('calling notification helpers', () => { }); it("includes the creator's first name when describing a call", () => { + const conversation = getDefaultConversation({ + systemGivenName: 'Luigi', + }); assert.strictEqual( getCallingNotificationText( { callMode: CallMode.Group, conversationId: 'abc123', - creator: { - firstName: 'Luigi', - isMe: false, - title: 'Luigi Mario', - }, + creator: conversation, ended: false, deviceCount: 1, 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", () => { + const conversation = getDefaultConversation({ + systemGivenName: undefined, + title: 'Luigi Mario', + }); assert.strictEqual( getCallingNotificationText( { callMode: CallMode.Group, conversationId: 'abc123', - creator: { - isMe: false, - title: 'Luigi Mario', - }, + creator: conversation, ended: false, deviceCount: 1, maxDevices: 23, @@ -74,16 +75,15 @@ describe('calling notification helpers', () => { }); it('has a special message if you were the one to start the call', () => { + const conversation = getDefaultConversation({ + isMe: true, + }); assert.strictEqual( getCallingNotificationText( { callMode: CallMode.Group, conversationId: 'abc123', - creator: { - firstName: 'ShouldBeIgnored', - isMe: true, - title: 'ShouldBeIgnored Smith', - }, + creator: conversation, ended: false, deviceCount: 1, maxDevices: 23, diff --git a/ts/util/callingNotification.ts b/ts/util/callingNotification.ts index 7227e74cbd..66537ea4db 100644 --- a/ts/util/callingNotification.ts +++ b/ts/util/callingNotification.ts @@ -5,6 +5,7 @@ import type { LocalizerType } from '../types/Util'; import { CallMode } from '../types/Calling'; import { missingCaseError } from './missingCaseError'; import * as log from '../logging/log'; +import type { ConversationType } from '../state/ducks/conversations'; type DirectCallNotificationType = { callMode: CallMode.Direct; @@ -20,11 +21,7 @@ type GroupCallNotificationType = { activeCallConversationId?: string; callMode: CallMode.Group; conversationId: string; - creator?: { - firstName?: string; - isMe?: boolean; - title: string; - }; + creator?: ConversationType; ended: boolean; deviceCount: number; maxDevices: number; @@ -90,7 +87,7 @@ function getGroupCallNotificationText( return i18n('calling__call-notification__started-by-you'); } return i18n('calling__call-notification__started', [ - notification.creator.firstName || notification.creator.title, + notification.creator.systemGivenName ?? notification.creator.title, ]); }