event name is changed from onUser to onMessage

This commit is contained in:
crusader 2020-12-02 11:45:20 +09:00
parent 3a83f3b523
commit caf46d7bd4
2 changed files with 13 additions and 13 deletions

View File

@ -78,7 +78,7 @@ export const defaultOptions: DefaultOptions = {
export type OnShow4NotificationWindow = () => Promise<void>; export type OnShow4NotificationWindow = () => Promise<void>;
export type OnClose4NotificationWindow = () => Promise<void>; export type OnClose4NotificationWindow = () => Promise<void>;
export type OnClick4NotificationWindow = () => Promise<void>; export type OnClick4NotificationWindow = () => Promise<void>;
export type OnUser4NotificationWindow = ( export type OnMessage4NotificationWindow = (
channel: string, channel: string,
...args: any[] ...args: any[]
) => Promise<void>; ) => Promise<void>;
@ -95,7 +95,7 @@ export interface Notification {
onShow?: OnShow4NotificationWindow; onShow?: OnShow4NotificationWindow;
onClose?: OnClose4NotificationWindow; onClose?: OnClose4NotificationWindow;
onClick?: OnClick4NotificationWindow; onClick?: OnClick4NotificationWindow;
onUser?: OnUser4NotificationWindow; onMessage?: OnMessage4NotificationWindow;
} }
class WindowPooler { class WindowPooler {
@ -542,8 +542,8 @@ export class NotificationService {
this.__onClick4NotificationWindow.bind(this) this.__onClick4NotificationWindow.bind(this)
); );
Electron.ipcMain.on( Electron.ipcMain.on(
NotificationWindowChannel.onUser, NotificationWindowChannel.onMessage,
this.__onUser4NotificationWindow.bind(this) this.__onMessage4NotificationWindow.bind(this)
); );
Electron.screen.on( Electron.screen.on(
@ -570,8 +570,8 @@ export class NotificationService {
this.__onClick4NotificationWindow.bind(this) this.__onClick4NotificationWindow.bind(this)
); );
Electron.ipcMain.off( Electron.ipcMain.off(
NotificationWindowChannel.onUser, NotificationWindowChannel.onMessage,
this.__onUser4NotificationWindow.bind(this) this.__onMessage4NotificationWindow.bind(this)
); );
Electron.screen.off( Electron.screen.off(
@ -612,18 +612,18 @@ export class NotificationService {
activated.notification.onClick(); activated.notification.onClick();
} }
private __onUser4NotificationWindow( private __onMessage4NotificationWindow(
event: Electron.IpcMainEvent, event: Electron.IpcMainEvent,
notificationId: number, notificationId: number,
channel: string, channel: string,
...args: any[] ...args: any[]
): void { ): void {
const activated = this.__findActivatedByNotificationId(notificationId); const activated = this.__findActivatedByNotificationId(notificationId);
if (!activated || !activated.notification.onUser) { if (!activated || !activated.notification.onMessage) {
return; return;
} }
activated.notification.onUser(channel, ...args); activated.notification.onMessage(channel, ...args);
} }
private __onDisplayAdded4ElectronScreen( private __onDisplayAdded4ElectronScreen(

View File

@ -1,11 +1,11 @@
export enum NotificationChannel { export enum NotificationChannel {
init4NotificationWindow = 'notification-electron::NotificationChannel::init4NotificationWindow', init4NotificationWindow = 'notification-electron::NotificationChannel::init4Window',
ready4NotificationWindow = 'notification-electron::NotificationChannel::ready4NotificationWindow', ready4NotificationWindow = 'notification-electron::NotificationChannel::ready4Window',
reset4NotificationWindow = 'notification-electron::NotificationChannel::reset4NotificationWindow', reset4NotificationWindow = 'notification-electron::NotificationChannel::reset4Window',
} }
export enum NotificationWindowChannel { export enum NotificationWindowChannel {
onClose = 'notification-electron::NotificationWindowChannel::onClose', onClose = 'notification-electron::NotificationWindowChannel::onClose',
onClick = 'notification-electron::NotificationWindowChannel::onClick', onClick = 'notification-electron::NotificationWindowChannel::onClick',
onUser = 'notification-electron::NotificationWindowChannel::onUser', onMessage = 'notification-electron::NotificationWindowChannel::onMessage',
} }