Update „new device“ toast texts and buttons (#10200)
This commit is contained in:
parent
e6fe7b7ea8
commit
880428ab94
9 changed files with 336 additions and 90 deletions
|
@ -14,6 +14,8 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
|
||||
import { _t } from "../languageHandler";
|
||||
import dis from "../dispatcher/dispatcher";
|
||||
import { MatrixClientPeg } from "../MatrixClientPeg";
|
||||
|
@ -21,6 +23,9 @@ 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;
|
||||
|
@ -31,16 +36,21 @@ export const showToast = async (deviceId: string): Promise<void> => {
|
|||
|
||||
const onAccept = (): void => {
|
||||
DeviceListener.sharedInstance().dismissUnverifiedSessions([deviceId]);
|
||||
};
|
||||
|
||||
const onReject = (): void => {
|
||||
DeviceListener.sharedInstance().dismissUnverifiedSessions([deviceId]);
|
||||
dis.dispatch({
|
||||
action: Action.ViewUserDeviceSettings,
|
||||
});
|
||||
};
|
||||
|
||||
const onReject = (): void => {
|
||||
DeviceListener.sharedInstance().dismissUnverifiedSessions([deviceId]);
|
||||
};
|
||||
|
||||
const device = await cli.getDevice(deviceId);
|
||||
const extendedDevice = {
|
||||
...device,
|
||||
isVerified: isDeviceVerified(device, cli),
|
||||
deviceType: DeviceType.Unknown,
|
||||
};
|
||||
|
||||
ToastStore.sharedInstance().addOrReplaceToast({
|
||||
key: toastKey(deviceId),
|
||||
|
@ -48,13 +58,10 @@ export const showToast = async (deviceId: string): Promise<void> => {
|
|||
icon: "verification_warning",
|
||||
props: {
|
||||
description: device.display_name,
|
||||
detail: _t("%(deviceId)s from %(ip)s", {
|
||||
deviceId,
|
||||
ip: device.last_seen_ip,
|
||||
}),
|
||||
acceptLabel: _t("Check your devices"),
|
||||
detail: <DeviceMetaData device={extendedDevice} />,
|
||||
acceptLabel: _t("Yes, it was me"),
|
||||
onAccept,
|
||||
rejectLabel: _t("Later"),
|
||||
rejectLabel: _t("No"),
|
||||
onReject,
|
||||
},
|
||||
component: GenericToast,
|
Loading…
Add table
Add a link
Reference in a new issue