diff --git a/demo/index.html b/demo/index.html index 02b43529..de399937 100644 --- a/demo/index.html +++ b/demo/index.html @@ -208,7 +208,7 @@ color: color || 'white', sticky: shouldStick, data: { - hello: 'hello word' + hello: `Notification with id ${num} clicked')` }, tag: tag, company: company, @@ -219,7 +219,7 @@ const ssfNotificationHandler = new window.ssf.Notification(notf.title, notf); const onclick = (event) => { event.target.close(); - alert('notification clicked: ' + event.target.data.title); + alert('notification clicked: ' + event.target.data.hello); }; ssfNotificationHandler.addEventListener('click', onclick); diff --git a/spec/appMenu.spec.ts b/spec/appMenu.spec.ts index a1b37b12..20412f22 100644 --- a/spec/appMenu.spec.ts +++ b/spec/appMenu.spec.ts @@ -63,6 +63,7 @@ jest.mock('../src/app/window-handler', () => { return { windowHandler: { createMoreInfoWindow: jest.fn(), + getMainWindow: jest.fn(), }, }; }); diff --git a/src/app/app-menu.ts b/src/app/app-menu.ts index 7cb66354..186ef850 100644 --- a/src/app/app-menu.ts +++ b/src/app/app-menu.ts @@ -90,6 +90,15 @@ export class AppMenu { logger.info(`app-menu: built menu from the provided template`); Menu.setApplicationMenu(this.menu); logger.info(`app-menu: set application menu`); + + // Remove the default menu for window + // as we use custom popup menu + if (isWindowsOS) { + const mainWindow = windowHandler.getMainWindow(); + if (mainWindow && windowExists(mainWindow)) { + mainWindow.setMenuBarVisibility(false); + } + } } /** diff --git a/src/app/window-actions.ts b/src/app/window-actions.ts index 05595029..3a3ac444 100644 --- a/src/app/window-actions.ts +++ b/src/app/window-actions.ts @@ -129,6 +129,7 @@ export const handleKeyPress = (key: number): void => { const focusedWindow = BrowserWindow.getFocusedWindow(); if (focusedWindow && !focusedWindow.isDestroyed() && focusedWindow.isFullScreen()) { + logger.info(`window-actions: exiting fullscreen by esc key action`); focusedWindow.setFullScreen(false); } break; @@ -139,6 +140,7 @@ export const handleKeyPress = (key: number): void => { } const browserWin = BrowserWindow.getFocusedWindow(); if (browserWin && !browserWin.isDestroyed()) { + logger.info(`window-actions: popping up menu by alt key action`); showPopupMenu({ window: browserWin }); } break; diff --git a/src/common/logger.ts b/src/common/logger.ts index 4d2f9219..d5c49d70 100644 --- a/src/common/logger.ts +++ b/src/common/logger.ts @@ -1,4 +1,4 @@ -import { app } from 'electron'; +import { app, BrowserWindow } from 'electron'; import electronLog, { LogLevel, transports } from 'electron-log'; import * as fs from 'fs'; import * as path from 'path'; @@ -210,6 +210,10 @@ class Logger { } if (this.loggerWindow) { + const browserWindow = BrowserWindow.fromWebContents(this.loggerWindow); + if (!(!!browserWindow && typeof browserWindow.isDestroyed === 'function' && !browserWindow.isDestroyed())) { + return; + } this.loggerWindow.send('log', { msgs: [ logMsg ], logLevel: this.desiredLogLevel, showInConsole: this.showInConsole }); return; } diff --git a/src/renderer/notification-ssf-hendler.ts b/src/renderer/notification-ssf-hendler.ts index 1d84780d..01343689 100644 --- a/src/renderer/notification-ssf-hendler.ts +++ b/src/renderer/notification-ssf-hendler.ts @@ -23,8 +23,8 @@ export default class SSFNotificationHandler { constructor(title, options) { this.id = latestID; latestID++; - this._data = { ...title, ...options }; - notification.showNotification(this._data, this.eventHandlers.onClick); + notification.showNotification({ ...options, title, id: this.id }, this.eventHandlers.onClick); + this._data = options.data; } /**