From ff61e8e9f873b3a3250c9cec106bce14b88bdef2 Mon Sep 17 00:00:00 2001 From: BenShelton Date: Mon, 26 Apr 2021 12:16:49 +0100 Subject: [PATCH] feat(media/ipc): allow empty args, add media:clear & display:clear events --- packages/media/app/main/src/ipc.ts | 5 +++++ packages/media/app/preload/types/electron-api.d.ts | 4 ++-- packages/media/types/ipc.d.ts | 10 +++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/packages/media/app/main/src/ipc.ts b/packages/media/app/main/src/ipc.ts index b236da7..493940c 100644 --- a/packages/media/app/main/src/ipc.ts +++ b/packages/media/app/main/src/ipc.ts @@ -39,4 +39,9 @@ export function initIPC (): void { const displayWindow = await refocusDisplayWindow() displayWindow.webContents.send('display:image', { src: args.src } as DisplayImage['Args']) }) + + ipcMain.on('media:clear', async () => { + const displayWindow = await refocusDisplayWindow() + displayWindow.webContents.send('display:clear') + }) } diff --git a/packages/media/app/preload/types/electron-api.d.ts b/packages/media/app/preload/types/electron-api.d.ts index 2405bb0..bc92f75 100644 --- a/packages/media/app/preload/types/electron-api.d.ts +++ b/packages/media/app/preload/types/electron-api.d.ts @@ -1,7 +1,7 @@ interface ElectronApi { invoke (channel: string, args?: T['Args']): Promise - send (channel: string, args: T['Args']): void - on (channel: string, cb: (args: T['Args']) => void): void + send (channel: string, args: T['Args']): void + on (channel: string, cb: (args: T['Args']) => void): void } declare interface Window { diff --git a/packages/media/types/ipc.d.ts b/packages/media/types/ipc.d.ts index b33c3c2..75f7e3c 100644 --- a/packages/media/types/ipc.d.ts +++ b/packages/media/types/ipc.d.ts @@ -10,7 +10,7 @@ interface Invoke { } interface Send { - Args: unknown + Args?: unknown } export interface CatalogUpdate extends Invoke { @@ -31,8 +31,16 @@ export interface MediaImage extends Send { } } +export interface MediaClear extends Send { + Args?: never +} + export interface DisplayImage extends Send { Args: { src: string } } + +export interface DisplayClear extends Send { + Args?: never +}