diff options
Diffstat (limited to 'src/index.js')
-rw-r--r-- | src/index.js | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/src/index.js b/src/index.js index 3244c44ad..e7fa7da6d 100644 --- a/src/index.js +++ b/src/index.js | |||
@@ -2,16 +2,18 @@ import { app, BrowserWindow, shell } from 'electron'; | |||
2 | import fs from 'fs-extra'; | 2 | import fs from 'fs-extra'; |
3 | import path from 'path'; | 3 | import path from 'path'; |
4 | 4 | ||
5 | // eslint-disable-next-line | 5 | /* eslint-disable */ |
6 | if (require('electron-squirrel-startup')) app.quit(); | 6 | if (require('electron-squirrel-startup')) app.quit(); |
7 | 7 | ||
8 | import windowStateKeeper from 'electron-window-state'; // eslint-disable-line | 8 | import windowStateKeeper from 'electron-window-state'; |
9 | 9 | ||
10 | import { isDevMode, isWindows } from './environment'; // eslint-disable-line | 10 | import { isDevMode, isWindows } from './environment'; |
11 | import ipcApi from './electron/ipc-api'; // eslint-disable-line | 11 | import ipcApi from './electron/ipc-api'; |
12 | import Settings from './electron/Settings'; // eslint-disable-line | 12 | import Tray from './lib/Tray'; |
13 | import { appId } from './package.json'; // eslint-disable-line | 13 | import Settings from './electron/Settings'; |
14 | import './electron/exception'; // eslint-disable-line | 14 | import { appId } from './package.json'; |
15 | import './electron/exception'; | ||
16 | /* eslint-enable */ | ||
15 | 17 | ||
16 | // Keep a global reference of the window object, if you don't, the window will | 18 | // Keep a global reference of the window object, if you don't, the window will |
17 | // be closed automatically when the JavaScript object is garbage collected. | 19 | // be closed automatically when the JavaScript object is garbage collected. |
@@ -47,8 +49,11 @@ const createWindow = async () => { | |||
47 | autoHideMenuBar: true, | 49 | autoHideMenuBar: true, |
48 | }); | 50 | }); |
49 | 51 | ||
52 | // Initialize System Tray | ||
53 | const trayIcon = new Tray(mainWindow); | ||
54 | |||
50 | // Initialize ipcApi | 55 | // Initialize ipcApi |
51 | ipcApi({ mainWindow, settings }); | 56 | ipcApi({ mainWindow, settings, trayIcon }); |
52 | 57 | ||
53 | // Manage Window State | 58 | // Manage Window State |
54 | mainWindowState.manage(mainWindow); | 59 | mainWindowState.manage(mainWindow); |
@@ -85,6 +90,7 @@ const createWindow = async () => { | |||
85 | 90 | ||
86 | if (settings.get('minimizeToSystemTray')) { | 91 | if (settings.get('minimizeToSystemTray')) { |
87 | mainWindow.setSkipTaskbar(true); | 92 | mainWindow.setSkipTaskbar(true); |
93 | trayIcon.show(); | ||
88 | } | 94 | } |
89 | }); | 95 | }); |
90 | 96 | ||
@@ -102,6 +108,10 @@ const createWindow = async () => { | |||
102 | if (app.wasMaximized) { | 108 | if (app.wasMaximized) { |
103 | mainWindow.maximize(); | 109 | mainWindow.maximize(); |
104 | } | 110 | } |
111 | |||
112 | if (!settings.get('enableSystemTray')) { | ||
113 | trayIcon.hide(); | ||
114 | } | ||
105 | }); | 115 | }); |
106 | 116 | ||
107 | mainWindow.on('show', () => { | 117 | mainWindow.on('show', () => { |