2020-05-22 20:29:53 +08:00
|
|
|
/*
|
2024-09-09 21:57:16 +08:00
|
|
|
Copyright 2024 New Vector Ltd.
|
2020-05-22 20:29:53 +08:00
|
|
|
Copyright 2020 The Matrix.org Foundation C.I.C.
|
|
|
|
|
2024-09-09 21:57:16 +08:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
|
|
|
|
Please see LICENSE files in the repository root for full details.
|
2020-05-22 20:29:53 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
import { _t } from "../languageHandler";
|
|
|
|
import dis from "../dispatcher/dispatcher";
|
|
|
|
import DeviceListener from "../DeviceListener";
|
|
|
|
import GenericToast from "../components/views/toasts/GenericToast";
|
|
|
|
import ToastStore from "../stores/ToastStore";
|
2021-10-30 06:11:39 +08:00
|
|
|
import { Action } from "../dispatcher/actions";
|
2022-12-06 14:18:03 +08:00
|
|
|
import { snoozeBulkUnverifiedDeviceReminder } from "../utils/device/snoozeBulkUnverifiedDeviceReminder";
|
2020-05-22 20:29:53 +08:00
|
|
|
|
|
|
|
const TOAST_KEY = "reviewsessions";
|
|
|
|
|
2023-01-12 21:25:14 +08:00
|
|
|
export const showToast = (deviceIds: Set<string>): void => {
|
|
|
|
const onAccept = (): void => {
|
2020-05-22 20:29:53 +08:00
|
|
|
DeviceListener.sharedInstance().dismissUnverifiedSessions(deviceIds);
|
|
|
|
|
|
|
|
dis.dispatch({
|
2022-10-11 17:10:55 +08:00
|
|
|
action: Action.ViewUserDeviceSettings,
|
2020-05-22 20:29:53 +08:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2023-01-12 21:25:14 +08:00
|
|
|
const onReject = (): void => {
|
2020-05-22 20:29:53 +08:00
|
|
|
DeviceListener.sharedInstance().dismissUnverifiedSessions(deviceIds);
|
2022-12-06 14:18:03 +08:00
|
|
|
snoozeBulkUnverifiedDeviceReminder();
|
2020-05-22 20:29:53 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
ToastStore.sharedInstance().addOrReplaceToast({
|
|
|
|
key: TOAST_KEY,
|
2023-09-26 01:12:41 +08:00
|
|
|
title: _t("encryption|verification|unverified_sessions_toast_title"),
|
2020-05-22 20:29:53 +08:00
|
|
|
icon: "verification_warning",
|
|
|
|
props: {
|
2023-09-26 01:12:41 +08:00
|
|
|
description: _t("encryption|verification|unverified_sessions_toast_description"),
|
2024-07-30 20:57:15 +08:00
|
|
|
primaryLabel: _t("action|review"),
|
|
|
|
onPrimaryClick: onAccept,
|
|
|
|
secondaryLabel: _t("encryption|verification|unverified_sessions_toast_reject"),
|
|
|
|
onSecondaryClick: onReject,
|
2020-05-22 20:29:53 +08:00
|
|
|
},
|
|
|
|
component: GenericToast,
|
|
|
|
priority: 50,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2023-01-12 21:25:14 +08:00
|
|
|
export const hideToast = (): void => {
|
2020-05-22 20:29:53 +08:00
|
|
|
ToastStore.sharedInstance().dismissToast(TOAST_KEY);
|
|
|
|
};
|