Skip to content

Commit 96cd727

Browse files
RiotRobott3chguy
authored andcommitted
Add mechanism for Electron to render toasts (element-hq#30765) (element-hq#30767)
Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
1 parent 599f386 commit 96cd727

2 files changed

Lines changed: 3 additions & 16 deletions

File tree

src/vector/platform/ElectronPlatform.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,7 @@ export default class ElectronPlatform extends BasePlatform {
185185
await this.ipc.call("callDisplayMediaCallback", source ?? { id: "", name: "", thumbnailURL: "" });
186186
});
187187

188-
this.electron.on("showToast", async (ev, { title, description, priority = 40 }) => {
189-
await this.clientStartedPromiseWithResolvers.promise;
190-
188+
this.electron.on("showToast", (ev, { title, description, priority = 40 }) => {
191189
const key = uniqueId("electron_showToast_");
192190
const onPrimaryClick = (): void => {
193191
ToastStore.sharedInstance().dismissToast(key);

test/unit-tests/vector/platform/ElectronPlatform-test.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -130,25 +130,14 @@ describe("ElectronPlatform", () => {
130130

131131
it("should show a toast when showToast is fired", async () => {
132132
new ElectronPlatform();
133-
dispatcher.dispatch(
134-
{
135-
action: "client_started",
136-
},
137-
true,
138-
);
139133
const spy = jest.spyOn(ToastStore.sharedInstance(), "addOrReplaceToast");
140134

141135
const [event, handler] = getElectronEventHandlerCall("showToast")!;
142136
handler({} as any, { title: "title", description: "description" });
143137

144138
expect(event).toBeTruthy();
145-
await waitFor(() =>
146-
expect(spy).toHaveBeenCalledWith(
147-
expect.objectContaining({
148-
title: "title",
149-
props: expect.objectContaining({ description: "description" }),
150-
}),
151-
),
139+
expect(spy).toHaveBeenCalledWith(
140+
expect.objectContaining({ title: "title", props: expect.objectContaining({ description: "description" }) }),
152141
);
153142
});
154143

0 commit comments

Comments
 (0)