2020-10-30 20:34:04 +00:00
|
|
|
// Copyright 2020 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2020-07-29 23:20:05 +00:00
|
|
|
import { LocalizerType } from '../types/Util';
|
|
|
|
|
|
|
|
export type ProfileNameChangeType = {
|
|
|
|
type: 'name';
|
|
|
|
oldName: string;
|
|
|
|
newName: string;
|
|
|
|
};
|
2020-10-16 18:31:57 +00:00
|
|
|
type ContactType = {
|
|
|
|
title: string;
|
|
|
|
name?: string;
|
|
|
|
};
|
2020-07-29 23:20:05 +00:00
|
|
|
|
|
|
|
export function getStringForProfileChange(
|
|
|
|
change: ProfileNameChangeType,
|
2020-10-16 18:31:57 +00:00
|
|
|
changedContact: ContactType,
|
2020-07-29 23:20:05 +00:00
|
|
|
i18n: LocalizerType
|
2020-09-14 21:56:35 +00:00
|
|
|
): string {
|
2020-07-29 23:20:05 +00:00
|
|
|
if (change.type === 'name') {
|
|
|
|
return changedContact.name
|
|
|
|
? i18n('contactChangedProfileName', {
|
|
|
|
sender: changedContact.title,
|
|
|
|
oldProfile: change.oldName,
|
|
|
|
newProfile: change.newName,
|
|
|
|
})
|
|
|
|
: i18n('changedProfileName', {
|
|
|
|
oldProfile: change.oldName,
|
|
|
|
newProfile: change.newName,
|
|
|
|
});
|
|
|
|
}
|
2020-09-14 21:56:35 +00:00
|
|
|
|
|
|
|
throw new Error('TimelineItem: Unknown type!');
|
2020-07-29 23:20:05 +00:00
|
|
|
}
|