2021-09-07 19:55:03 +00:00
|
|
|
// Copyright 2018-2021 Signal Messenger, LLC
|
2020-10-30 20:34:04 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2018-07-09 21:29:13 +00:00
|
|
|
import React from 'react';
|
|
|
|
|
2021-09-07 19:55:03 +00:00
|
|
|
import { SystemMessage } from './SystemMessage';
|
2018-07-09 21:29:13 +00:00
|
|
|
import { ContactName } from './ContactName';
|
|
|
|
import { Intl } from '../Intl';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { LocalizerType } from '../../types/Util';
|
2018-07-09 21:29:13 +00:00
|
|
|
|
|
|
|
import { missingCaseError } from '../../util/missingCaseError';
|
|
|
|
|
2021-09-16 16:15:43 +00:00
|
|
|
type Contact = { title: string };
|
2018-07-09 21:29:13 +00:00
|
|
|
|
2019-03-20 17:42:28 +00:00
|
|
|
export type PropsData = {
|
2018-07-09 21:29:13 +00:00
|
|
|
type: 'markVerified' | 'markNotVerified';
|
|
|
|
isLocal: boolean;
|
|
|
|
contact: Contact;
|
2019-03-20 17:42:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
type PropsHousekeeping = {
|
2019-01-14 21:49:58 +00:00
|
|
|
i18n: LocalizerType;
|
2019-03-20 17:42:28 +00:00
|
|
|
};
|
|
|
|
|
2020-08-26 18:40:23 +00:00
|
|
|
export type Props = PropsData & PropsHousekeeping;
|
2018-07-09 21:29:13 +00:00
|
|
|
|
|
|
|
export class VerificationNotification extends React.Component<Props> {
|
2020-09-14 19:51:27 +00:00
|
|
|
public getStringId(): string {
|
2018-07-09 21:29:13 +00:00
|
|
|
const { isLocal, type } = this.props;
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case 'markVerified':
|
|
|
|
return isLocal
|
|
|
|
? 'youMarkedAsVerified'
|
|
|
|
: 'youMarkedAsVerifiedOtherDevice';
|
|
|
|
case 'markNotVerified':
|
|
|
|
return isLocal
|
|
|
|
? 'youMarkedAsNotVerified'
|
|
|
|
: 'youMarkedAsNotVerifiedOtherDevice';
|
|
|
|
default:
|
|
|
|
throw missingCaseError(type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-14 19:51:27 +00:00
|
|
|
public renderContents(): JSX.Element {
|
2018-07-09 21:29:13 +00:00
|
|
|
const { contact, i18n } = this.props;
|
|
|
|
const id = this.getStringId();
|
|
|
|
|
|
|
|
return (
|
2021-09-07 19:55:03 +00:00
|
|
|
<Intl
|
|
|
|
id={id}
|
|
|
|
components={[
|
|
|
|
<ContactName
|
|
|
|
key="external-1"
|
|
|
|
title={contact.title}
|
|
|
|
module="module-verification-notification__contact"
|
|
|
|
/>,
|
|
|
|
]}
|
|
|
|
i18n={i18n}
|
|
|
|
/>
|
2018-07-09 21:29:13 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-11-12 23:44:20 +00:00
|
|
|
public override render(): JSX.Element {
|
2018-07-09 21:29:13 +00:00
|
|
|
const { type } = this.props;
|
2021-09-07 19:55:03 +00:00
|
|
|
const icon = type === 'markVerified' ? 'verified' : 'verified-not';
|
2018-07-09 21:29:13 +00:00
|
|
|
|
2021-09-07 19:55:03 +00:00
|
|
|
return <SystemMessage icon={icon} contents={this.renderContents()} />;
|
2018-07-09 21:29:13 +00:00
|
|
|
}
|
|
|
|
}
|