Skip to content

Commit

Permalink
feat(media/ipc): allow empty args, add media:clear & display:clear ev…
Browse files Browse the repository at this point in the history
…ents
  • Loading branch information
BenShelton committed May 11, 2021
1 parent 73e2487 commit ff61e8e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
5 changes: 5 additions & 0 deletions packages/media/app/main/src/ipc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
})
}
4 changes: 2 additions & 2 deletions packages/media/app/preload/types/electron-api.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
interface ElectronApi {
invoke<T extends { Args?: unknown, Response: unknown }> (channel: string, args?: T['Args']): Promise<T['Response']>
send<T extends { Args: unknown }> (channel: string, args: T['Args']): void
on<T extends { Args: unknown }> (channel: string, cb: (args: T['Args']) => void): void
send<T extends { Args?: unknown }> (channel: string, args: T['Args']): void
on<T extends { Args?: unknown }> (channel: string, cb: (args: T['Args']) => void): void
}

declare interface Window {
Expand Down
10 changes: 9 additions & 1 deletion packages/media/types/ipc.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ interface Invoke {
}

interface Send {
Args: unknown
Args?: unknown
}

export interface CatalogUpdate extends Invoke {
Expand All @@ -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
}

0 comments on commit ff61e8e

Please # to comment.