// Copyright 2021 Signal Messenger, LLC // SPDX-License-Identifier: AGPL-3.0-only import * as React from 'react'; import classNames from 'classnames'; import type { LocalizerType } from '../types/Util'; import { Avatar, AvatarBlur } from './Avatar'; import { Spinner } from './Spinner'; import { Button, ButtonVariant } from './Button'; import { GroupDescription } from './conversation/GroupDescription'; import type { PreJoinConversationType } from '../state/ducks/conversations'; type CallbackType = () => unknown; export type DataPropsType = PreJoinConversationType & { readonly join: CallbackType; readonly onClose: CallbackType; }; export type HousekeepingPropsType = { readonly i18n: LocalizerType; }; export type PropsType = DataPropsType & HousekeepingPropsType; function focusRef(el: HTMLElement | null) { if (el) { el.focus(); } } export const GroupV2JoinDialog = React.memo(function GroupV2JoinDialogInner( props: PropsType ) { const [isWorking, setIsWorking] = React.useState(false); const [isJoining, setIsJoining] = React.useState(false); const { approvalRequired, avatar, groupDescription, i18n, join, memberCount, onClose, title, } = props; const joinString = approvalRequired ? i18n('icu:GroupV2--join--request-to-join-button') : i18n('icu:GroupV2--join--join-button'); const wrappedJoin = React.useCallback(() => { setIsWorking(true); setIsJoining(true); join(); }, [join, setIsJoining, setIsWorking]); const wrappedClose = React.useCallback(() => { setIsWorking(true); onClose(); }, [onClose, setIsWorking]); return (