signal-desktop/ts/components/conversation/UnsupportedMessage.tsx

107 lines
2.5 KiB
TypeScript
Raw Normal View History

2023-01-03 19:55:46 +00:00
// Copyright 2019 Signal Messenger, LLC
2020-10-30 20:34:04 +00:00
// SPDX-License-Identifier: AGPL-3.0-only
import React from 'react';
import { SystemMessage } from './SystemMessage';
2021-08-26 20:51:55 +00:00
import { Button, ButtonSize, ButtonVariant } from '../Button';
import { ContactName } from './ContactName';
import { Intl } from '../Intl';
import type { LocalizerType } from '../../types/Util';
import { openLinkInWebBrowser } from '../../util/openLinkInWebBrowser';
export type ContactType = {
id: string;
2020-07-24 01:35:32 +00:00
phoneNumber?: string;
profileName?: string;
2020-07-24 01:35:32 +00:00
title: string;
name?: string;
isMe: boolean;
};
export type PropsData = {
canProcessNow: boolean;
contact: ContactType;
};
type PropsHousekeeping = {
i18n: LocalizerType;
};
export type Props = PropsData & PropsHousekeeping;
function UnsupportedMessageContents({ canProcessNow, contact, i18n }: Props) {
const { isMe } = contact;
const contactName = (
<span key="external-1" className="module-unsupported-message__contact">
<ContactName
title={contact.title}
module="module-unsupported-message__contact"
/>
</span>
);
if (isMe) {
if (canProcessNow) {
return (
<Intl
2023-03-30 00:03:25 +00:00
id="icu:Message--unsupported-message-ask-to-resend"
components={{ contact: contactName }}
i18n={i18n}
/>
);
}
return <Intl id="icu:Message--from-me-unsupported-message" i18n={i18n} />;
}
if (canProcessNow) {
return (
<Intl
2023-03-30 00:03:25 +00:00
id="icu:Message--from-me-unsupported-message-ask-to-resend"
i18n={i18n}
/>
);
}
return (
<Intl
id="icu:Message--unsupported-message"
i18n={i18n}
components={{
contact: contactName,
}}
/>
);
}
2022-11-18 00:45:19 +00:00
export function UnsupportedMessage({
2020-09-14 19:51:27 +00:00
canProcessNow,
contact,
i18n,
2022-11-18 00:45:19 +00:00
}: Props): JSX.Element {
2020-09-14 19:51:27 +00:00
return (
<SystemMessage
icon={canProcessNow ? 'unsupported--can-process' : 'unsupported'}
contents={
<UnsupportedMessageContents
canProcessNow={canProcessNow}
contact={contact}
i18n={i18n}
2020-09-14 19:51:27 +00:00
/>
}
button={
canProcessNow ? undefined : (
<div className="SystemMessage__line">
<Button
onClick={() => {
openLinkInWebBrowser('https://signal.org/download');
}}
size={ButtonSize.Small}
variant={ButtonVariant.SystemMessage}
>
2023-03-30 00:03:25 +00:00
{i18n('icu:Message--update-signal')}
</Button>
</div>
)
}
/>
2020-09-14 19:51:27 +00:00
);
2022-11-18 00:45:19 +00:00
}