2020-10-30 20:34:04 +00:00
|
|
|
// Copyright 2019-2020 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2019-06-10 21:40:02 +00:00
|
|
|
import React from 'react';
|
|
|
|
import classNames from 'classnames';
|
|
|
|
|
|
|
|
import { ContactName } from './ContactName';
|
|
|
|
import { Intl } from '../Intl';
|
|
|
|
import { LocalizerType } from '../../types/Util';
|
|
|
|
|
2021-01-14 18:07:05 +00:00
|
|
|
export type ContactType = {
|
2019-06-10 21:40:02 +00:00
|
|
|
id: string;
|
2020-07-24 01:35:32 +00:00
|
|
|
phoneNumber?: string;
|
2019-06-10 21:40:02 +00:00
|
|
|
profileName?: string;
|
2020-07-24 01:35:32 +00:00
|
|
|
title: string;
|
2019-06-10 21:40:02 +00:00
|
|
|
name?: string;
|
|
|
|
isMe: boolean;
|
2021-01-14 18:07:05 +00:00
|
|
|
};
|
2019-06-10 21:40:02 +00:00
|
|
|
|
|
|
|
export type PropsData = {
|
|
|
|
canProcessNow: boolean;
|
|
|
|
contact: ContactType;
|
|
|
|
};
|
|
|
|
|
|
|
|
export type PropsActions = {
|
|
|
|
downloadNewVersion: () => unknown;
|
|
|
|
};
|
|
|
|
|
2019-05-31 22:42:01 +00:00
|
|
|
type PropsHousekeeping = {
|
|
|
|
i18n: LocalizerType;
|
|
|
|
};
|
|
|
|
|
2020-08-26 18:40:23 +00:00
|
|
|
export type Props = PropsData & PropsHousekeeping & PropsActions;
|
2019-06-10 21:40:02 +00:00
|
|
|
|
2020-09-14 19:51:27 +00:00
|
|
|
export const UnsupportedMessage = ({
|
|
|
|
canProcessNow,
|
|
|
|
contact,
|
|
|
|
i18n,
|
|
|
|
downloadNewVersion,
|
|
|
|
}: Props): JSX.Element => {
|
|
|
|
const { isMe } = contact;
|
2019-06-10 21:40:02 +00:00
|
|
|
|
2020-09-14 19:51:27 +00:00
|
|
|
const otherStringId = canProcessNow
|
|
|
|
? 'Message--unsupported-message-ask-to-resend'
|
|
|
|
: 'Message--unsupported-message';
|
|
|
|
const meStringId = canProcessNow
|
|
|
|
? 'Message--from-me-unsupported-message-ask-to-resend'
|
|
|
|
: 'Message--from-me-unsupported-message';
|
|
|
|
const stringId = isMe ? meStringId : otherStringId;
|
2019-06-10 21:40:02 +00:00
|
|
|
|
2020-09-14 19:51:27 +00:00
|
|
|
return (
|
|
|
|
<div className="module-unsupported-message">
|
|
|
|
<div
|
|
|
|
className={classNames(
|
|
|
|
'module-unsupported-message__icon',
|
|
|
|
canProcessNow ? 'module-unsupported-message__icon--can-process' : null
|
2019-06-10 21:40:02 +00:00
|
|
|
)}
|
2020-09-14 19:51:27 +00:00
|
|
|
/>
|
|
|
|
<div className="module-unsupported-message__text">
|
|
|
|
<Intl
|
|
|
|
id={stringId}
|
|
|
|
components={[
|
|
|
|
<span
|
|
|
|
key="external-1"
|
|
|
|
className="module-unsupported-message__contact"
|
|
|
|
>
|
|
|
|
<ContactName
|
|
|
|
name={contact.name}
|
|
|
|
profileName={contact.profileName}
|
|
|
|
phoneNumber={contact.phoneNumber}
|
|
|
|
title={contact.title}
|
|
|
|
module="module-unsupported-message__contact"
|
|
|
|
i18n={i18n}
|
|
|
|
/>
|
|
|
|
</span>,
|
|
|
|
]}
|
|
|
|
i18n={i18n}
|
|
|
|
/>
|
2019-06-10 21:40:02 +00:00
|
|
|
</div>
|
2020-09-14 19:51:27 +00:00
|
|
|
{canProcessNow ? null : (
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
onClick={() => {
|
|
|
|
downloadNewVersion();
|
|
|
|
}}
|
|
|
|
className="module-unsupported-message__button"
|
|
|
|
>
|
|
|
|
{i18n('Message--update-signal')}
|
|
|
|
</button>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|