mirror of
https://github.com/vector-im/element-web.git
synced 2025-12-01 07:21:43 +01:00
Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
c7c0e91fdc
commit
2e8e6e92cc
3
src/@types/global.d.ts
vendored
3
src/@types/global.d.ts
vendored
@ -68,7 +68,8 @@ type ElectronChannel =
|
|||||||
| "openDesktopCapturerSourcePicker"
|
| "openDesktopCapturerSourcePicker"
|
||||||
| "userAccessToken"
|
| "userAccessToken"
|
||||||
| "homeserverUrl"
|
| "homeserverUrl"
|
||||||
| "serverSupportedVersions";
|
| "serverSupportedVersions"
|
||||||
|
| "showToast";
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
// use `number` as the return type in all cases for globalThis.set{Interval,Timeout},
|
// use `number` as the return type in all cases for globalThis.set{Interval,Timeout},
|
||||||
|
|||||||
@ -18,6 +18,7 @@ import {
|
|||||||
} from "matrix-js-sdk/src/matrix";
|
} from "matrix-js-sdk/src/matrix";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { logger } from "matrix-js-sdk/src/logger";
|
import { logger } from "matrix-js-sdk/src/logger";
|
||||||
|
import { uniqueId } from "lodash";
|
||||||
|
|
||||||
import BasePlatform, { UpdateCheckStatus, type UpdateStatus } from "../../BasePlatform";
|
import BasePlatform, { UpdateCheckStatus, type UpdateStatus } from "../../BasePlatform";
|
||||||
import type BaseEventIndexManager from "../../indexing/BaseEventIndexManager";
|
import type BaseEventIndexManager from "../../indexing/BaseEventIndexManager";
|
||||||
@ -43,6 +44,7 @@ import { SeshatIndexManager } from "./SeshatIndexManager";
|
|||||||
import { IPCManager } from "./IPCManager";
|
import { IPCManager } from "./IPCManager";
|
||||||
import { _t } from "../../languageHandler";
|
import { _t } from "../../languageHandler";
|
||||||
import { BadgeOverlayRenderer } from "../../favicon";
|
import { BadgeOverlayRenderer } from "../../favicon";
|
||||||
|
import GenericToast from "../../components/views/toasts/GenericToast.tsx";
|
||||||
|
|
||||||
interface SquirrelUpdate {
|
interface SquirrelUpdate {
|
||||||
releaseNotes: string;
|
releaseNotes: string;
|
||||||
@ -182,6 +184,25 @@ export default class ElectronPlatform extends BasePlatform {
|
|||||||
await this.ipc.call("callDisplayMediaCallback", source ?? { id: "", name: "", thumbnailURL: "" });
|
await this.ipc.call("callDisplayMediaCallback", source ?? { id: "", name: "", thumbnailURL: "" });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.electron.on("showToast", (ev, { title, description, priority = 40 }) => {
|
||||||
|
const key = uniqueId("electron_showToast_");
|
||||||
|
const onPrimaryClick = (): void => {
|
||||||
|
ToastStore.sharedInstance().dismissToast(key);
|
||||||
|
};
|
||||||
|
|
||||||
|
ToastStore.sharedInstance().addOrReplaceToast({
|
||||||
|
key,
|
||||||
|
title,
|
||||||
|
props: {
|
||||||
|
description,
|
||||||
|
primaryLabel: _t("action|dismiss"),
|
||||||
|
onPrimaryClick,
|
||||||
|
},
|
||||||
|
component: GenericToast,
|
||||||
|
priority,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
BreadcrumbsStore.instance.on(UPDATE_EVENT, this.onBreadcrumbsUpdate);
|
BreadcrumbsStore.instance.on(UPDATE_EVENT, this.onBreadcrumbsUpdate);
|
||||||
|
|
||||||
this.initialised = this.initialise();
|
this.initialised = this.initialise();
|
||||||
|
|||||||
@ -21,6 +21,7 @@ import DesktopCapturerSourcePicker from "../../../../src/components/views/elemen
|
|||||||
import ElectronPlatform from "../../../../src/vector/platform/ElectronPlatform";
|
import ElectronPlatform from "../../../../src/vector/platform/ElectronPlatform";
|
||||||
import { setupLanguageMock } from "../../../setup/setupLanguage";
|
import { setupLanguageMock } from "../../../setup/setupLanguage";
|
||||||
import { stubClient } from "../../../test-utils";
|
import { stubClient } from "../../../test-utils";
|
||||||
|
import ToastStore from "../../../../src/stores/ToastStore.ts";
|
||||||
|
|
||||||
jest.mock("../../../../src/rageshake/rageshake", () => ({
|
jest.mock("../../../../src/rageshake/rageshake", () => ({
|
||||||
flush: jest.fn(),
|
flush: jest.fn(),
|
||||||
@ -127,6 +128,19 @@ describe("ElectronPlatform", () => {
|
|||||||
expect(plat.ipc.call).toHaveBeenCalledWith("callDisplayMediaCallback", "source");
|
expect(plat.ipc.call).toHaveBeenCalledWith("callDisplayMediaCallback", "source");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should show a toast when showToast is fired", async () => {
|
||||||
|
new ElectronPlatform();
|
||||||
|
const spy = jest.spyOn(ToastStore.sharedInstance(), "addOrReplaceToast");
|
||||||
|
|
||||||
|
const [event, handler] = getElectronEventHandlerCall("showToast")!;
|
||||||
|
handler({} as any, { title: "title", description: "description" });
|
||||||
|
|
||||||
|
expect(event).toBeTruthy();
|
||||||
|
expect(spy).toHaveBeenCalledWith(
|
||||||
|
expect.objectContaining({ title: "title", props: expect.objectContaining({ description: "description" }) }),
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
describe("updates", () => {
|
describe("updates", () => {
|
||||||
it("dispatches on check updates action", () => {
|
it("dispatches on check updates action", () => {
|
||||||
new ElectronPlatform();
|
new ElectronPlatform();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user