2023-01-03 11:55:46 -08:00
|
|
|
// Copyright 2020 Signal Messenger, LLC
|
2020-10-30 15:34:04 -05:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2020-10-01 14:09:15 -05:00
|
|
|
import React, { useRef, useEffect } from 'react';
|
2021-10-26 14:15:33 -05:00
|
|
|
import type { LocalizerType } from '../types/Util';
|
2021-08-05 20:17:05 -04:00
|
|
|
import { AvatarColors } from '../types/Colors';
|
2022-12-09 13:37:45 -07:00
|
|
|
import { Avatar, AvatarSize } from './Avatar';
|
2024-05-15 14:48:02 -07:00
|
|
|
import { I18n } from './I18n';
|
2020-10-01 14:09:15 -05:00
|
|
|
import { ContactName } from './conversation/ContactName';
|
2021-10-26 14:15:33 -05:00
|
|
|
import type { ConversationType } from '../state/ducks/conversations';
|
2020-10-01 14:09:15 -05:00
|
|
|
|
2023-12-20 08:16:21 -08:00
|
|
|
export type Props = {
|
2021-04-30 14:40:25 -05:00
|
|
|
conversation: Pick<
|
|
|
|
ConversationType,
|
|
|
|
| 'acceptedMessageRequest'
|
2024-07-11 12:44:09 -07:00
|
|
|
| 'avatarUrl'
|
2021-04-30 14:40:25 -05:00
|
|
|
| 'color'
|
2021-05-07 17:21:10 -05:00
|
|
|
| 'isMe'
|
2021-04-30 14:40:25 -05:00
|
|
|
| 'name'
|
|
|
|
| 'phoneNumber'
|
|
|
|
| 'profileName'
|
|
|
|
| 'sharedGroupNames'
|
|
|
|
| 'title'
|
2024-07-11 12:44:09 -07:00
|
|
|
| 'unblurredAvatarUrl'
|
2021-04-30 14:40:25 -05:00
|
|
|
>;
|
2020-10-01 14:09:15 -05:00
|
|
|
i18n: LocalizerType;
|
|
|
|
close: () => void;
|
2021-01-14 12:07:05 -06:00
|
|
|
};
|
2020-10-01 14:09:15 -05:00
|
|
|
|
|
|
|
const AUTO_CLOSE_MS = 10000;
|
|
|
|
|
2022-11-17 16:45:19 -08:00
|
|
|
export function CallNeedPermissionScreen({
|
2020-11-06 11:36:37 -06:00
|
|
|
conversation,
|
2020-10-01 14:09:15 -05:00
|
|
|
i18n,
|
|
|
|
close,
|
2022-11-17 16:45:19 -08:00
|
|
|
}: Props): JSX.Element {
|
2023-03-29 17:03:25 -07:00
|
|
|
const title = conversation.title || i18n('icu:unknownContact');
|
2020-10-01 14:09:15 -05: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 14:40:25 -05:00
|
|
|
acceptedMessageRequest={conversation.acceptedMessageRequest}
|
2024-07-11 12:44:09 -07:00
|
|
|
avatarUrl={conversation.avatarUrl}
|
2021-12-01 11:24:00 -06:00
|
|
|
badge={undefined}
|
2021-08-05 20:17:05 -04:00
|
|
|
color={conversation.color || AvatarColors[0]}
|
2020-10-01 14:09:15 -05:00
|
|
|
noteToSelf={false}
|
|
|
|
conversationType="direct"
|
|
|
|
i18n={i18n}
|
2021-05-07 17:21:10 -05:00
|
|
|
isMe={conversation.isMe}
|
2020-11-06 11:36:37 -06:00
|
|
|
phoneNumber={conversation.phoneNumber}
|
|
|
|
profileName={conversation.profileName}
|
|
|
|
title={conversation.title}
|
2021-05-07 17:21:10 -05:00
|
|
|
sharedGroupNames={conversation.sharedGroupNames}
|
2022-12-09 13:37:45 -07:00
|
|
|
size={AvatarSize.EIGHTY}
|
2020-10-01 14:09:15 -05:00
|
|
|
/>
|
|
|
|
|
|
|
|
<p className="module-call-need-permission-screen__text">
|
2024-05-15 14:48:02 -07:00
|
|
|
<I18n
|
2020-10-01 14:09:15 -05:00
|
|
|
i18n={i18n}
|
2023-03-29 17:03:25 -07:00
|
|
|
id="icu:callNeedPermission"
|
2023-03-27 16:37:39 -07:00
|
|
|
components={{
|
|
|
|
title: <ContactName title={title} />,
|
|
|
|
}}
|
2020-10-01 14:09:15 -05:00
|
|
|
/>
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
className="module-call-need-permission-screen__button"
|
|
|
|
onClick={() => {
|
|
|
|
close();
|
|
|
|
}}
|
|
|
|
>
|
2023-03-29 17:03:25 -07:00
|
|
|
{i18n('icu:close')}
|
2020-10-01 14:09:15 -05:00
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
);
|
2022-11-17 16:45:19 -08:00
|
|
|
}
|