import React from 'react'; import { Box, Text, IconButton, Icon, Icons, Scroll } from 'folds'; import { Page, PageContent, PageHeader } from '../../../components/page'; import { SequenceCard } from '../../../components/sequence-card'; import { SequenceCardStyle } from '../styles.css'; import { SettingTile } from '../../../components/setting-tile'; import { useDeviceIds, useDeviceList, useSplitCurrentDevice } from '../../../hooks/useDeviceList'; import { useMatrixClient } from '../../../hooks/useMatrixClient'; import { LocalBackup } from './LocalBackup'; import { DeviceLogoutBtn, DeviceKeyDetails, DeviceTile, DeviceTilePlaceholder } from './DeviceTile'; import { OtherDevices } from './OtherDevices'; import { DeviceVerificationOptions, EnableVerification, VerificationStatusBadge, VerifyCurrentDeviceTile, } from './Verification'; import { useDeviceVerificationStatus, useUnverifiedDeviceCount, VerificationStatus, } from '../../../hooks/useDeviceVerificationStatus'; import { useSecretStorageDefaultKeyId, useSecretStorageKeyContent, } from '../../../hooks/useSecretStorage'; import { useCrossSigningActive } from '../../../hooks/useCrossSigning'; import { BackupRestoreTile } from '../../../components/BackupRestore'; function DevicesPlaceholder() { return ( ); } type DevicesProps = { requestClose: () => void; }; export function Devices({ requestClose }: DevicesProps) { const mx = useMatrixClient(); const crypto = mx.getCrypto(); const crossSigningActive = useCrossSigningActive(); const [devices, refreshDeviceList] = useDeviceList(); const [currentDevice, otherDevices] = useSplitCurrentDevice(devices); const verificationStatus = useDeviceVerificationStatus( crypto, mx.getSafeUserId(), currentDevice?.device_id ); const otherDevicesId = useDeviceIds(otherDevices); const unverifiedDeviceCount = useUnverifiedDeviceCount( crypto, mx.getSafeUserId(), otherDevicesId ); const defaultSecretStorageKeyId = useSecretStorageDefaultKeyId(); const defaultSecretStorageKeyContent = useSecretStorageKeyContent( defaultSecretStorageKeyId ?? '' ); return ( Devices Security {crossSigningActive && ( )} } /> Current {currentDevice ? ( } > {crypto && } {crossSigningActive && verificationStatus === VerificationStatus.Unverified && defaultSecretStorageKeyId && defaultSecretStorageKeyContent && ( )} {crypto && verificationStatus === VerificationStatus.Verified && ( )} ) : ( )} {devices === undefined && } {otherDevices && ( )} ); }