* Switch to rendering svg icons rather than masking them in left panel Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Remove unused stylesheet Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Switch to rendering svg icons rather than masking them for ExternalLink Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Switch to rendering svg icons rather than masking them for TabbedView Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Switch to rendering svg icons rather than masking them for JoinRuleDropdown Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Switch to rendering svg icons rather than masking them in ManageRestrictedJoinRuleDialog Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Switch to rendering svg icons rather than masking them in LeaveSpaceDialog Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Switch to rendering svg icons rather than masking them in ReplyPreview Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Switch to rendering svg icons rather than masking them in SearchBox Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Switch to rendering svg icons rather than masking them in RoomStatusBar Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix advanced.svg Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Update snapshots Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Update screenshots Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Iterate Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Fix bad merge conflict resolution Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Switch to rendering svg icons rather than masking them in Toasts Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Switch to rendering svg icons rather than masking them in RoomInfoLine Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Switch to rendering svg icons rather than masking them in UploadBar Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Remove unused class Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Switch to rendering svg icons rather than masking them in ConfirmSpaceUserActionDialog Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Switch to rendering svg icons rather than masking them in FeedbackDialog Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Switch to rendering svg icons rather than masking them in KeyBackupFailedDialog Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Switch to rendering svg icons rather than masking them in CopyableText Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Switch to rendering svg icons rather than masking them in EventTile Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Switch to rendering svg icons rather than masking them in InviteReason Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Delint Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Update tests Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Add test Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> * Add test Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --------- Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
69 lines
2.4 KiB
TypeScript
69 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 "../DeviceListener";
|
|
import ToastStore from "../stores/ToastStore";
|
|
import GenericToast from "../components/views/toasts/GenericToast";
|
|
import { Action } from "../dispatcher/actions";
|
|
import { isDeviceVerified } from "../utils/device/isDeviceVerified";
|
|
import { DeviceType } from "../utils/device/parseUserAgent";
|
|
import { DeviceMetaData } from "../components/views/settings/devices/DeviceMetaData";
|
|
|
|
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 = {
|
|
...device,
|
|
isVerified: await isDeviceVerified(cli, deviceId),
|
|
deviceType: DeviceType.Unknown,
|
|
};
|
|
|
|
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));
|
|
};
|