mirror of
https://github.com/Novaloop-AG/healthchat-web.git
synced 2026-11-23 23:59:57 +00:00
69ee8fd96a
* Add commercial licence and update config files * Update license in headers * Revert "Update license in headers" This reverts commit 7ed7949485e88889a9ffc8075a9df1f8e936777e. * Update only spdx id * Remove LicenseRef- from package.json LicenseRef- no longer allowed in npm v3 package.json This fixes the warning in the logs and failing build check.
68 lines
2.3 KiB
TypeScript
68 lines
2.3 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 { _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: "verification_warning",
|
|
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));
|
|
};
|