fix: Typescript (Fix issues with notification, menu & logger modules) (#682)

* Typescript - Fix issues with notification, menu & logger

* Typescript - Update unit test case and fix logger circular import

* Typescript - Fix the notification argument issue
This commit is contained in:
Kiran Niranjan 2019-06-15 01:02:32 +05:30 committed by Vishwas Shashidhar
parent 36613e3023
commit 2bddbc56ec
6 changed files with 21 additions and 5 deletions

View File

@ -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);

View File

@ -63,6 +63,7 @@ jest.mock('../src/app/window-handler', () => {
return {
windowHandler: {
createMoreInfoWindow: jest.fn(),
getMainWindow: jest.fn(),
},
};
});

View File

@ -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);
}
}
}
/**

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}
/**