From bd6f2c2faf9c07dd9ffdd40215cb7f90b0f8441a Mon Sep 17 00:00:00 2001 From: Michael George Attard Date: Mon, 30 Oct 2017 22:46:33 +0100 Subject: [PATCH 1/6] Clean up of `main.js` --- src/main/windows/main.js | 41 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/src/main/windows/main.js b/src/main/windows/main.js index 104ac132..eb222f64 100644 --- a/src/main/windows/main.js +++ b/src/main/windows/main.js @@ -28,7 +28,10 @@ function init (state, options) { return main.win.show() } - const initialBounds = Object.assign(config.WINDOW_INITIAL_BOUNDS, state.saved.bounds) + const initialBounds = { + ...config.WINDOW_INITIAL_BOUNDS, + ...state.saved.bounds + } const win = main.win = new electron.BrowserWindow({ backgroundColor: '#282828', @@ -57,7 +60,7 @@ function init (state, options) { win.setSheetOffset(config.UI_HEADER_HEIGHT) } - win.webContents.on('dom-ready', function () { + win.webContents.on('dom-ready', () => { menu.onToggleFullScreen(main.win.isFullScreen()) }) @@ -73,27 +76,27 @@ function init (state, options) { win.on('hide', onWindowBlur) win.on('show', onWindowFocus) - win.on('enter-full-screen', function () { + win.on('enter-full-screen', () => { menu.onToggleFullScreen(true) send('fullscreenChanged', true) win.setMenuBarVisibility(false) }) - win.on('leave-full-screen', function () { + win.on('leave-full-screen', () => { menu.onToggleFullScreen(false) send('fullscreenChanged', false) win.setMenuBarVisibility(true) }) - win.on('move', debounce(function (e) { + win.on('move', debounce(e => { send('windowBoundsChanged', e.sender.getBounds()) }, 1000)) - win.on('resize', debounce(function (e) { + win.on('resize', debounce(e => { send('windowBoundsChanged', e.sender.getBounds()) }, 1000)) - win.on('close', function (e) { + win.on('close', e => { if (process.platform !== 'darwin') { const tray = require('../tray') if (!tray.hasTray()) { @@ -138,28 +141,20 @@ function setAspectRatio (aspectRatio) { function setBounds (bounds, maximize) { // Do nothing in fullscreen if (!main.win || main.win.isFullScreen()) { - log('setBounds: not setting bounds because we\'re in full screen') + log(`setBounds: not setting bounds because we're in full screen`) return } // Maximize or minimize, if the second argument is present - let willBeMaximized - if (maximize === true) { - if (!main.win.isMaximized()) { - log('setBounds: maximizing') - main.win.maximize() - } - willBeMaximized = true - } else if (maximize === false) { - if (main.win.isMaximized()) { - log('setBounds: unmaximizing') - main.win.unmaximize() - } - willBeMaximized = false - } else { - willBeMaximized = main.win.isMaximized() + if (maximize === true && !main.win.isMaximized()) { + log('setBounds: maximizing') + main.win.maximize() + } else if (maximize === false && main.win.isMaximized()) { + log('setBounds: unmaximizing') + main.win.unmaximize() } + const willBeMaximized = typeof maximize === 'boolean' ? maximize : main.win.isMaximized // Assuming we're not maximized or maximizing, set the window size if (!willBeMaximized) { log('setBounds: setting bounds to ' + JSON.stringify(bounds)) From a30eedbec9eb2d9aeaf1def03fd9c7f99614e5c3 Mon Sep 17 00:00:00 2001 From: Borewit Date: Wed, 23 May 2018 21:00:55 +0200 Subject: [PATCH 2/6] Update music-metadata to 1.1.0, which I expected to be part of #1396. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c4dcfebc..f43d270f 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "location-history": "^1.0.0", "material-ui": "^0.17.0", "mkdirp": "^0.5.1", - "music-metadata": "^1.0.0", + "music-metadata": "^1.1.0", "network-address": "^1.1.0", "parse-torrent": "^5.7.3", "prettier-bytes": "^1.0.1", From 4b51fb9255e4f2e436fb071d5822d4ee81df2327 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Fri, 25 May 2018 00:20:39 -0700 Subject: [PATCH 3/6] e -> err --- src/main/external-player.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/external-player.js b/src/main/external-player.js index 58e4925f..d378a623 100644 --- a/src/main/external-player.js +++ b/src/main/external-player.js @@ -70,7 +70,7 @@ function spawnExternal (playerPath, args) { proc = null }) - proc.on('error', e => { - log('External player error', e) + proc.on('error', err => { + log('External player error', err) }) } From 2c9b30572168488039c00ab2cfcb04083ca935a2 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Fri, 25 May 2018 00:28:14 -0700 Subject: [PATCH 4/6] style --- src/main/handlers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/handlers.js b/src/main/handlers.js index dfef92c8..22bc65c6 100644 --- a/src/main/handlers.js +++ b/src/main/handlers.js @@ -229,7 +229,7 @@ function uninstallWin32 () { hive: Registry.HKCU, key: `\\Software\\Classes\\${protocol}` }) - protocolKey.destroy(() => { }) + protocolKey.destroy(() => {}) } } From 7251967ef520c0c31597bc81ba36b89e843bf605 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Fri, 25 May 2018 00:28:46 -0700 Subject: [PATCH 5/6] style --- src/main/handlers.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/handlers.js b/src/main/handlers.js index 22bc65c6..3c42e443 100644 --- a/src/main/handlers.js +++ b/src/main/handlers.js @@ -261,7 +261,7 @@ function uninstallWin32 () { hive: Registry.HKCU, // HKEY_CURRENT_USER key: `\\Software\\Classes\\${ext}` }) - extKey.destroy(() => { }) + extKey.destroy(() => {}) } } } From 6bf38611e8747c860bf74dc8f24ea0613a9ddd7f Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Fri, 25 May 2018 00:30:54 -0700 Subject: [PATCH 6/6] fix bug, function needs to be invoked --- src/main/windows/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/windows/main.js b/src/main/windows/main.js index c9a20333..f310ad70 100644 --- a/src/main/windows/main.js +++ b/src/main/windows/main.js @@ -151,7 +151,7 @@ function setBounds (bounds, maximize) { main.win.unmaximize() } - const willBeMaximized = typeof maximize === 'boolean' ? maximize : main.win.isMaximized + const willBeMaximized = typeof maximize === 'boolean' ? maximize : main.win.isMaximized() // Assuming we're not maximized or maximizing, set the window size if (!willBeMaximized) { log(`setBounds: setting bounds to ${JSON.stringify(bounds)}`)