import { FunctionComponent, useEffect, useRef, useState } from 'react' import { AlertDialog, AlertDialogDescription, AlertDialogLabel } from '@reach/alert-dialog' import { STRING_SIGN_OUT_CONFIRMATION } from '@/Strings' import { WebApplication } from '@/UIModels/Application' import { AppState } from '@/UIModels/AppState' import { observer } from 'mobx-react-lite' import { ApplicationGroup } from '@/UIModels/ApplicationGroup' import { isDesktopApplication } from '@/Utils' type Props = { application: WebApplication appState: AppState applicationGroup: ApplicationGroup } const ConfirmSignoutModal: FunctionComponent = ({ application, appState, applicationGroup }) => { const [deleteLocalBackups, setDeleteLocalBackups] = useState(false) const cancelRef = useRef(null) function closeDialog() { appState.accountMenu.setSigningOut(false) } const [localBackupsCount, setLocalBackupsCount] = useState(0) useEffect(() => { application.desktopDevice?.localBackupsCount().then(setLocalBackupsCount).catch(console.error) }, [appState.accountMenu.signingOut, application.desktopDevice]) const workspaces = applicationGroup.getDescriptors() const showWorkspaceWarning = workspaces.length > 1 && isDesktopApplication() return (
Sign out workspace?

{STRING_SIGN_OUT_CONFIRMATION}

{showWorkspaceWarning && ( <>

Note: Because you have other workspaces signed in, this sign out may leave logs and other metadata of your session on this device. For a more robust sign out that performs a hard clear of all app-related data, use the Sign out all workspaces option under Switch workspace.

)}
{localBackupsCount > 0 && (
)}
) } ConfirmSignoutModal.displayName = 'ConfirmSignoutModal' const ConfirmSignoutContainer = (props: Props) => { if (!props.appState.accountMenu.signingOut) { return null } return } export default observer(ConfirmSignoutContainer)