2021-01-14 18:07:05 +00:00
|
|
|
// Copyright 2020-2021 Signal Messenger, LLC
|
2020-10-30 20:34:04 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2020-10-01 19:09:15 +00:00
|
|
|
import React, { useRef, useEffect } from 'react';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { LocalizerType } from '../types/Util';
|
2021-08-06 00:17:05 +00:00
|
|
|
import { AvatarColors } from '../types/Colors';
|
2020-10-01 19:09:15 +00:00
|
|
|
import { Avatar } from './Avatar';
|
|
|
|
import { Intl } from './Intl';
|
|
|
|
import { ContactName } from './conversation/ContactName';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { ConversationType } from '../state/ducks/conversations';
|
2020-10-01 19:09:15 +00:00
|
|
|
|
2021-01-14 18:07:05 +00:00
|
|
|
type Props = {
|
2021-04-30 19:40:25 +00:00
|
|
|
conversation: Pick<
|
|
|
|
ConversationType,
|
|
|
|
| 'acceptedMessageRequest'
|
|
|
|
| 'avatarPath'
|
|
|
|
| 'color'
|
2021-05-07 22:21:10 +00:00
|
|
|
| 'isMe'
|
2021-04-30 19:40:25 +00:00
|
|
|
| 'name'
|
|
|
|
| 'phoneNumber'
|
|
|
|
| 'profileName'
|
|
|
|
| 'sharedGroupNames'
|
|
|
|
| 'title'
|
|
|
|
| 'unblurredAvatarPath'
|
|
|
|
>;
|
2020-10-01 19:09:15 +00:00
|
|
|
i18n: LocalizerType;
|
|
|
|
close: () => void;
|
2021-01-14 18:07:05 +00:00
|
|
|
};
|
2020-10-01 19:09:15 +00:00
|
|
|
|
|
|
|
const AUTO_CLOSE_MS = 10000;
|
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function CallNeedPermissionScreen({
|
2020-11-06 17:36:37 +00:00
|
|
|
conversation,
|
2020-10-01 19:09:15 +00:00
|
|
|
i18n,
|
|
|
|
close,
|
2022-11-18 00:45:19 +00:00
|
|
|
}: Props): JSX.Element {
|
2020-11-06 17:36:37 +00:00
|
|
|
const title = conversation.title || i18n('unknownContact');
|
2020-10-01 19:09:15 +00:00
|
|
|
|
|
|
|
const autoCloseAtRef = useRef<number>(Date.now() + AUTO_CLOSE_MS);
|
|
|
|
useEffect(() => {
|
|
|
|
const timeout = setTimeout(close, autoCloseAtRef.current - Date.now());
|
|
|
|
return clearTimeout.bind(null, timeout);
|
|
|
|
}, [autoCloseAtRef, close]);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="module-call-need-permission-screen">
|
|
|
|
<Avatar
|
2021-04-30 19:40:25 +00:00
|
|
|
acceptedMessageRequest={conversation.acceptedMessageRequest}
|
2020-11-06 17:36:37 +00:00
|
|
|
avatarPath={conversation.avatarPath}
|
2021-12-01 17:24:00 +00:00
|
|
|
badge={undefined}
|
2021-08-06 00:17:05 +00:00
|
|
|
color={conversation.color || AvatarColors[0]}
|
2020-10-01 19:09:15 +00:00
|
|
|
noteToSelf={false}
|
|
|
|
conversationType="direct"
|
|
|
|
i18n={i18n}
|
2021-05-07 22:21:10 +00:00
|
|
|
isMe={conversation.isMe}
|
2020-11-06 17:36:37 +00:00
|
|
|
phoneNumber={conversation.phoneNumber}
|
|
|
|
profileName={conversation.profileName}
|
|
|
|
title={conversation.title}
|
2021-05-07 22:21:10 +00:00
|
|
|
sharedGroupNames={conversation.sharedGroupNames}
|
2020-10-01 19:09:15 +00:00
|
|
|
size={112}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<p className="module-call-need-permission-screen__text">
|
|
|
|
<Intl
|
|
|
|
i18n={i18n}
|
|
|
|
id="callNeedPermission"
|
2021-09-16 16:15:43 +00:00
|
|
|
components={[<ContactName title={title} />]}
|
2020-10-01 19:09:15 +00:00
|
|
|
/>
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
className="module-call-need-permission-screen__button"
|
|
|
|
onClick={() => {
|
|
|
|
close();
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{i18n('close')}
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
);
|
2022-11-18 00:45:19 +00:00
|
|
|
}
|