diff --git a/server/AppController.js b/server/AppController.js index 27bc62c..dcfe2f0 100644 --- a/server/AppController.js +++ b/server/AppController.js @@ -1,4 +1,4 @@ -const { Tray, Menu, nativeImage, NativeImage, MenuItem, nativeTheme } = require('electron'); +const { Tray, Menu, nativeImage, nativeTheme } = require('electron'); const path = require('path'); /** @@ -26,13 +26,10 @@ class AppController { /** @param {(BrowserWindowController)} browserWindowController */ constructor(browserWindowController) { - this.isActive = false; + this.isActive = true; this.theme = AppController.getCurrentThemeName(); this.tray = new Tray(nativeImage.createEmpty()); - this.setTrayImage(); - this.setTrayTooltip(); - this.handleActivateMenuItemClick = this.handleActivateMenuItemClick.bind(this); this.handleQuitClick = this.handleQuitClick.bind(this); this.handleThemeChange = this.handleThemeChange.bind(this); @@ -51,6 +48,8 @@ class AppController { ])); this.browserWindowController = browserWindowController; + + this.updateState(); } start() { @@ -137,17 +136,10 @@ class AppController { */ getImagePath(theme) { const pathToImage = this.isActive ? `assets/${theme}/icon-active.png` : `assets/${theme}/icon.png`; - - return path.join(process.cwd(), pathToImage); + return nativeImage.createFromPath(path.join(__dirname, `../${pathToImage}`)); } - /** - * @param {Electron.MenuItem} menuItem - * @private - */ - handleActivateMenuItemClick(menuItem) { - this.isActive = menuItem.checked; - + updateState() { this.setTrayImage(); this.setTrayTooltip(); @@ -158,6 +150,15 @@ class AppController { } } + /** + * @param {Electron.MenuItem} menuItem + * @private + */ + handleActivateMenuItemClick(menuItem) { + this.isActive = menuItem.checked; + this.updateState(); + } + /** @private */ handleQuitClick() { this.quitHandler();