/* * Wire * Copyright (C) 2022 Wire Swiss GmbH * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see http://www.gnu.org/licenses/. * */ import React, {useEffect, useState} from 'react'; import {Button, ButtonVariant} from '@wireapp/react-ui-kit'; import {ClientEntity} from 'src/script/client/ClientEntity'; import {WireIdentity} from 'src/script/E2EIdentity'; import {useKoSubscribableChildren} from 'Util/ComponentUtil'; import {t} from 'Util/LocalizerUtil'; import {Config} from '../../../../../../../Config'; import {MotionDuration} from '../../../../../../../motion/MotionDuration'; import {contentStyle} from '../../../components/PreferencesPage.styles'; import {DetailedDevice} from '../DetailedDevice'; interface DevicesPreferencesProps { device: ClientEntity; getFingerprint: (device: ClientEntity) => Promise; getDeviceIdentity?: (deviceId: string) => WireIdentity | undefined; onClose: () => void; onRemove: (device: ClientEntity) => void; onResetSession: (device: ClientEntity) => Promise; onVerify: (device: ClientEntity, verified: boolean) => void; } enum SessionResetState { CONFIRMATION = 'confirmation', ONGOING = 'ongoing', RESET = 'reset', } export const DeviceDetailsPreferences: React.FC = ({ device, getFingerprint, getDeviceIdentity, onVerify, onRemove, onClose, onResetSession, }) => { const {isVerified} = useKoSubscribableChildren(device.meta, ['isVerified']); const [resetState, setResetState] = useState(SessionResetState.RESET); const [fingerprint, setFingerprint] = useState(); const brandName = Config.getConfig().BRAND_NAME; const resetSession = async () => { setResetState(SessionResetState.ONGOING); await onResetSession(device); setTimeout(() => setResetState(SessionResetState.CONFIRMATION), MotionDuration.LONG); setTimeout(() => setResetState(SessionResetState.RESET), 5000); }; useEffect(() => { void getFingerprint(device).then(setFingerprint); }, [device, getFingerprint]); return (

{t('preferencesDeviceDetails')}

{t('preferencesDevicesSessionDetail')}

{resetState === SessionResetState.RESET && ( )} {resetState === SessionResetState.ONGOING && (

{t('preferencesDevicesSessionOngoing')}

)} {resetState === SessionResetState.CONFIRMATION && (

{t('preferencesDevicesSessionConfirmation')}

)}

{!device.isLegalHold() && (

{t('preferencesDevicesRemoveDetail')}

)}
); };