* Remove support for MSC3391 & MSC3852 As they were both rejected & closed. Synapse already removed support for MSC3852 which means it already did nothing: https://github.com/element-hq/synapse/pull/19430 * Update snapshot
68 lines
2.4 KiB
TypeScript
68 lines
2.4 KiB
TypeScript
/*
|
|
Copyright 2024 New Vector Ltd.
|
|
Copyright 2020 The Matrix.org Foundation C.I.C.
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
|
Please see LICENSE files in the repository root for full details.
|
|
*/
|
|
|
|
import React from "react";
|
|
import { ErrorSolidIcon } from "@vector-im/compound-design-tokens/assets/web/icons";
|
|
|
|
import { _t } from "../languageHandler";
|
|
import dis from "../dispatcher/dispatcher";
|
|
import { MatrixClientPeg } from "../MatrixClientPeg";
|
|
import { DeviceListener } from "../device-listener";
|
|
import ToastStore from "../stores/ToastStore";
|
|
import GenericToast from "../components/views/toasts/GenericToast";
|
|
import { Action } from "../dispatcher/actions";
|
|
import { isDeviceVerified } from "../utils/device/isDeviceVerified";
|
|
import { DeviceMetaData } from "../components/views/settings/devices/DeviceMetaData";
|
|
import type { ExtendedDevice } from "../components/views/settings/devices/types.ts";
|
|
|
|
function toastKey(deviceId: string): string {
|
|
return "unverified_session_" + deviceId;
|
|
}
|
|
|
|
export const showToast = async (deviceId: string): Promise<void> => {
|
|
const cli = MatrixClientPeg.safeGet();
|
|
|
|
const onAccept = (): void => {
|
|
DeviceListener.sharedInstance().dismissUnverifiedSessions([deviceId]);
|
|
};
|
|
|
|
const onReject = (): void => {
|
|
DeviceListener.sharedInstance().dismissUnverifiedSessions([deviceId]);
|
|
dis.dispatch({
|
|
action: Action.ViewUserDeviceSettings,
|
|
});
|
|
};
|
|
|
|
const device = await cli.getDevice(deviceId);
|
|
const extendedDevice: ExtendedDevice = {
|
|
...device,
|
|
isVerified: await isDeviceVerified(cli, deviceId),
|
|
};
|
|
|
|
ToastStore.sharedInstance().addOrReplaceToast({
|
|
key: toastKey(deviceId),
|
|
title: _t("encryption|verification|unverified_session_toast_title"),
|
|
icon: <ErrorSolidIcon color="var(--cpd-color-icon-critical-primary)" />,
|
|
props: {
|
|
description: device.display_name,
|
|
detail: <DeviceMetaData device={extendedDevice} />,
|
|
primaryLabel: _t("encryption|verification|unverified_session_toast_accept"),
|
|
onPrimaryClick: onAccept,
|
|
secondaryLabel: _t("action|no"),
|
|
onSecondaryClick: onReject,
|
|
destructive: "secondary",
|
|
},
|
|
component: GenericToast,
|
|
priority: 80,
|
|
});
|
|
};
|
|
|
|
export const hideToast = (deviceId: string): void => {
|
|
ToastStore.sharedInstance().dismissToast(toastKey(deviceId));
|
|
};
|