Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
@@ -97,6 +97,7 @@ export default class ElectronPlatform extends BasePlatform {
|
|||||||
private badgeOverlayRenderer?: BadgeOverlayRenderer;
|
private badgeOverlayRenderer?: BadgeOverlayRenderer;
|
||||||
private config!: IConfigOptions;
|
private config!: IConfigOptions;
|
||||||
private supportedSettings?: Record<string, boolean>;
|
private supportedSettings?: Record<string, boolean>;
|
||||||
|
private clientStartedPromiseWithResolvers = Promise.withResolvers<void>();
|
||||||
|
|
||||||
public constructor() {
|
public constructor() {
|
||||||
super();
|
super();
|
||||||
@@ -184,7 +185,9 @@ 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 }) => {
|
this.electron.on("showToast", async (ev, { title, description, priority = 40 }) => {
|
||||||
|
await this.clientStartedPromiseWithResolvers.promise;
|
||||||
|
|
||||||
const key = uniqueId("electron_showToast_");
|
const key = uniqueId("electron_showToast_");
|
||||||
const onPrimaryClick = (): void => {
|
const onPrimaryClick = (): void => {
|
||||||
ToastStore.sharedInstance().dismissToast(key);
|
ToastStore.sharedInstance().dismissToast(key);
|
||||||
@@ -214,6 +217,10 @@ export default class ElectronPlatform extends BasePlatform {
|
|||||||
if (["call_state"].includes(payload.action)) {
|
if (["call_state"].includes(payload.action)) {
|
||||||
this.electron.send("app_onAction", payload);
|
this.electron.send("app_onAction", payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (payload.action === "client_started") {
|
||||||
|
this.clientStartedPromiseWithResolvers.resolve();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async initialise(): Promise<void> {
|
private async initialise(): Promise<void> {
|
||||||
|
|||||||
@@ -130,14 +130,25 @@ describe("ElectronPlatform", () => {
|
|||||||
|
|
||||||
it("should show a toast when showToast is fired", async () => {
|
it("should show a toast when showToast is fired", async () => {
|
||||||
new ElectronPlatform();
|
new ElectronPlatform();
|
||||||
|
dispatcher.dispatch(
|
||||||
|
{
|
||||||
|
action: "client_started",
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
);
|
||||||
const spy = jest.spyOn(ToastStore.sharedInstance(), "addOrReplaceToast");
|
const spy = jest.spyOn(ToastStore.sharedInstance(), "addOrReplaceToast");
|
||||||
|
|
||||||
const [event, handler] = getElectronEventHandlerCall("showToast")!;
|
const [event, handler] = getElectronEventHandlerCall("showToast")!;
|
||||||
handler({} as any, { title: "title", description: "description" });
|
handler({} as any, { title: "title", description: "description" });
|
||||||
|
|
||||||
expect(event).toBeTruthy();
|
expect(event).toBeTruthy();
|
||||||
expect(spy).toHaveBeenCalledWith(
|
await waitFor(() =>
|
||||||
expect.objectContaining({ title: "title", props: expect.objectContaining({ description: "description" }) }),
|
expect(spy).toHaveBeenCalledWith(
|
||||||
|
expect.objectContaining({
|
||||||
|
title: "title",
|
||||||
|
props: expect.objectContaining({ description: "description" }),
|
||||||
|
}),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user