Introduce TitleTransition notification

This commit is contained in:
Fedor Indutny 2024-03-06 15:59:51 -08:00 committed by GitHub
parent 09b5e6ef50
commit 3469a748fb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
16 changed files with 336 additions and 51 deletions

View file

@ -29,6 +29,7 @@ import type { PropsData as TimerNotificationProps } from '../../components/conve
import type { PropsData as ChangeNumberNotificationProps } from '../../components/conversation/ChangeNumberNotification';
import type { PropsData as SafetyNumberNotificationProps } from '../../components/conversation/SafetyNumberNotification';
import type { PropsData as VerificationNotificationProps } from '../../components/conversation/VerificationNotification';
import type { PropsData as TitleTransitionNotificationProps } from '../../components/conversation/TitleTransitionNotification';
import type { PropsDataType as GroupsV2Props } from '../../components/conversation/GroupV2Change';
import type { PropsDataType as GroupV1MigrationPropsType } from '../../components/conversation/GroupV1Migration';
import type { PropsDataType as DeliveryIssuePropsType } from '../../components/conversation/DeliveryIssueNotification';
@ -129,6 +130,7 @@ import type { AnyPaymentEvent } from '../../types/Payment';
import { isPaymentNotificationEvent } from '../../types/Payment';
import {
getTitleNoDefault,
getTitle,
getNumber,
renderNumber,
} from '../../util/getTitle';
@ -922,6 +924,13 @@ export function getPropsForBubble(
timestamp,
};
}
if (isTitleTransitionNotification(message)) {
return {
type: 'titleTransitionNotification',
data: getPropsForTitleTransitionNotification(message),
timestamp,
};
}
if (isChatSessionRefreshed(message)) {
return {
type: 'chatSessionRefreshed',
@ -1490,6 +1499,31 @@ function getPropsForChangeNumberNotification(
};
}
// Title Transition Notification
export function isTitleTransitionNotification(
message: MessageWithUIFieldsType
): boolean {
return (
message.type === 'title-transition-notification' &&
message.titleTransition != null
);
}
function getPropsForTitleTransitionNotification(
message: MessageWithUIFieldsType
): TitleTransitionNotificationProps {
strictAssert(
message.titleTransition != null,
'Invalid attributes for title-transition-notification'
);
const { renderInfo } = message.titleTransition;
const oldTitle = getTitle(renderInfo);
return {
oldTitle,
};
}
// Chat Session Refreshed
export function isChatSessionRefreshed(