From b153d45248af3ccbfef7704f1d430bd38e4a2bd6 Mon Sep 17 00:00:00 2001 From: jeffvli Date: Tue, 17 Aug 2021 20:57:27 -0700 Subject: [PATCH] fixes to global shortcuts --- src/main.dev.js | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/main.dev.js b/src/main.dev.js index b88ba85..f2e04b7 100644 --- a/src/main.dev.js +++ b/src/main.dev.js @@ -111,20 +111,28 @@ const createWindow = async () => { globalShortcut.register('MediaPlayPause', () => { const storeValues = store.getState(); - if (storeValues.playQueue.status === 'PAUSED') { - store.dispatch(setStatus('PLAYING')); - } else { - store.dispatch(setStatus('PAUSED')); + if (storeValues.playQueue.entry.length >= 1) { + if (storeValues.playQueue.status === 'PAUSED') { + store.dispatch(setStatus('PLAYING')); + } else { + store.dispatch(setStatus('PAUSED')); + } } }); globalShortcut.register('MediaNextTrack', () => { - store.dispatch(incrementCurrentIndex('usingHotkey')); + const storeValues = store.getState(); + if (storeValues.playQueue.entry.length >= 1) { + store.dispatch(incrementCurrentIndex('usingHotkey')); + } }); globalShortcut.register('MediaPreviousTrack', () => { - store.dispatch(decrementCurrentIndex('usingHotkey')); - store.dispatch(fixPlayer2Index()); + const storeValues = store.getState(); + if (storeValues.playQueue.entry.length >= 1) { + store.dispatch(decrementCurrentIndex('usingHotkey')); + store.dispatch(fixPlayer2Index()); + } }); mainWindow.loadURL(`file://${__dirname}/index.html`); @@ -168,6 +176,7 @@ const createWindow = async () => { app.on('window-all-closed', () => { // Respect the OSX convention of having the application in memory even // after all windows have been closed + globalShortcut.unregisterAll(); if (process.platform !== 'darwin') { app.quit(); }