From d24ed02f5d6cce58ac4b44d7e047931a21d23a45 Mon Sep 17 00:00:00 2001 From: Ryzzzen Date: Tue, 3 Jul 2018 00:49:21 +0200 Subject: [PATCH] Fixed Tray - Fixed Tray - Updated text --- ChampionSelect.js | 2 +- main.js | 17 ++++++++--------- renderer.js | 2 ++ src/assets/js/ui.js | 21 ++++++++++++--------- src/index.html | 8 ++++---- 5 files changed, 27 insertions(+), 23 deletions(-) diff --git a/ChampionSelect.js b/ChampionSelect.js index 18d5058..7e73761 100644 --- a/ChampionSelect.js +++ b/ChampionSelect.js @@ -35,7 +35,7 @@ function updateDisplay() { if (Last === User.championId) return; if ((Last = User.championId) === 0) return; - if (Mana.store.get('enableTrayIcon')) UI.show(); + if (Mana.store.get('enableTrayIcon')) UI.tray(false); ProviderHandler.getChampionData(Mana.champions[User.championId], User.assignedPosition === "" ? null : User.assignedPosition, GameMode).then(data => { console.dir(data); diff --git a/main.js b/main.js index 8ca43cc..a40a54e 100644 --- a/main.js +++ b/main.js @@ -21,20 +21,19 @@ function createWindow () { win.loadURL(`file://${__dirname}/src/index.html`); win.setMenu(null); - win.once('ready-to-show', () => !tray ? win.show()); + win.once('ready-to-show', () => !tray ? win.show() : null); - ipcMain.on('tray', () => { - if (tray && !tray.isDestroyed()) return; + ipcMain.on('tray', (event, show) => { + if (show && tray && !tray.isDestroyed()) return; + else if (!show) { + if (!tray || tray && tray.isDestroyed()) return; + return tray.destroy(); + } tray = new Tray(__dirname + '/build/icon.png'); tray.setToolTip('Cliquez pour afficher ManaFlux'); - tray.on('click', () => win.isVisible() ? win.hide() : win.show()); - }); - - ipcMain.on('tray-destroy', (event, data) => { - if (!tray || tray && tray.isDestroyed()) return; - tray.destroy(); + tray.on('click', () => win.isVisible() ? win.hide() : win.showInactive()); }); ipcMain.on('auto-start', (event, enable) => { diff --git a/renderer.js b/renderer.js index fd063f5..f5ac0f1 100644 --- a/renderer.js +++ b/renderer.js @@ -22,6 +22,8 @@ Mana.version = require('./package.json').version; Mana.status = str => $('.status').text(str); Mana.store = new Store(); +if (Mana.store.get('enableTrayIcon')) UI.tray(); + console.log('Loading Storage...'); Mana.status('Loading Storage...'); diff --git a/src/assets/js/ui.js b/src/assets/js/ui.js index 0f96a4d..d469d92 100644 --- a/src/assets/js/ui.js +++ b/src/assets/js/ui.js @@ -4,18 +4,21 @@ UI.error = function(err) { $('#warning').show(); } -UI.show = function() { - ipcRenderer.send('destroy-tray'); - ipcRenderer.send('win-show'); +UI.tray = function(tray = true) { + console.log(`${tray ? 'Enabling' : 'Disabling'} Tray Mode.`); + + if (tray) { + ipcRenderer.send('win-hide'); + ipcRenderer.send('tray', true); + } + else { + ipcRenderer.send('tray', false); + ipcRenderer.send('win-show'); + } } -UI.tray = function() { - ipcRenderer.send('win-hide'); - ipcRenderer.send('tray'); -} - -UI.tray(); +window.onbeforeunload = (e) => UI.tray(false); ipcRenderer.on('error', (event, data) => UI.error(data)); /* diff --git a/src/index.html b/src/index.html index 0bfd101..af3e275 100644 --- a/src/index.html +++ b/src/index.html @@ -58,17 +58,17 @@

MANAFLUX

-

Démarrage automatique

+

Démarrage

- +

Barre des tâches

- - + +