/* * Copyright 2024 New Vector Ltd. * * SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only * Please see LICENSE files in the repository root for full details. */ import React, { JSX, lazy, MouseEventHandler } from "react"; import { Button, HelpMessage, InlineField, InlineSpinner, Label, Root, ToggleControl } from "@vector-im/compound-web"; import DownloadIcon from "@vector-im/compound-design-tokens/assets/web/icons/download"; import ShareIcon from "@vector-im/compound-design-tokens/assets/web/icons/share"; import { _t } from "../../../../languageHandler"; import { SettingsSection } from "../shared/SettingsSection"; import { useMatrixClientContext } from "../../../../contexts/MatrixClientContext"; import { useAsyncMemo } from "../../../../hooks/useAsyncMemo"; import Modal from "../../../../Modal"; import { SettingLevel } from "../../../../settings/SettingLevel"; import { useSettingValueAt } from "../../../../hooks/useSettings"; import SettingsStore from "../../../../settings/SettingsStore"; interface AdvancedPanelProps { /** * Callback for when the user clicks the button to reset their identity. */ onResetIdentityClick: MouseEventHandler; } /** * The advanced panel of the encryption settings. */ export function AdvancedPanel({ onResetIdentityClick }: AdvancedPanelProps): JSX.Element { return ( ); } interface EncryptionDetails { /** * Callback for when the user clicks the button to reset their identity. */ onResetIdentityClick: MouseEventHandler; } /** * The encryption details section of the advanced panel. */ function EncryptionDetails({ onResetIdentityClick }: EncryptionDetails): JSX.Element { const matrixClient = useMatrixClientContext(); // Null when the keys are not loaded yet const keys = useAsyncMemo( () => { const crypto = matrixClient.getCrypto(); return crypto ? crypto.getOwnDeviceKeys() : Promise.resolve(null); }, [matrixClient], null, ); return (
{_t("settings|encryption|advanced|details_title")}
{_t("settings|encryption|advanced|session_id")} {matrixClient.deviceId}
{_t("settings|encryption|advanced|session_key")} {keys ? keys.ed25519 : }
); } /** * Display the never send encrypted message to unverified devices setting. */ function OtherSettings(): JSX.Element | null { const blacklistUnverifiedDevices = useSettingValueAt(SettingLevel.DEVICE, "blacklistUnverifiedDevices"); const canSetValue = SettingsStore.canSetValue("blacklistUnverifiedDevices", null, SettingLevel.DEVICE); if (!canSetValue) return null; return ( { const checked = new FormData(evt.currentTarget).get("neverSendEncrypted") === "on"; await SettingsStore.setValue("blacklistUnverifiedDevices", null, SettingLevel.DEVICE, checked); }} > {_t("settings|encryption|advanced|other_people_device_title")} } > {_t("settings|encryption|advanced|other_people_device_description")} ); }