Browse Source

Generic OSX tray minimize fixes

reviewable/pr209/r1
Samuel Attard 6 years ago
parent
commit
3089a0fb01
  1. 2
      src/index.js
  2. 3
      src/main/constants.js
  3. 11
      src/main/features/core/controlBar.js
  4. 9
      src/main/features/core/tray.js

2
src/index.js

@ -26,7 +26,9 @@ import handleStartupEvent from './squirrel';
if (mainWindow) {
if (mainWindow.isMinimized()) mainWindow.restore();
mainWindow.focus();
mainWindow.show();
mainWindow.setSkipTaskbar(false);
if (app.dock && app.dock.show) app.dock.show();
}
});

3
src/main/constants.js

@ -1,7 +1,8 @@
export const LASTFM_API_KEY = process.env.GPMDP_LASTFM_API_KEY;
export const LASTFM_API_SECRET = process.env.GPMDP_LASTFM_API_SECRET;
if (LASTFM_API_KEY === '' || LASTFM_API_SECRET === '') {
if (!LASTFM_API_KEY || !LASTFM_API_SECRET ||
LASTFM_API_KEY === 'undefined' || LASTFM_API_SECRET === 'undefined') {
console.error('####################################'); // eslint-disable-line
console.error('############### ERROR ##############'); // eslint-disable-line
console.error('######### LASTFM API KEYS #########'); // eslint-disable-line

11
src/main/features/core/controlBar.js

@ -1,3 +1,5 @@
import { app } from 'electron';
Emitter.on('window:minimize', (event, windowID) => {
WindowManager.getByInternalID(windowID).minimize();
});
@ -18,8 +20,13 @@ Emitter.on('window:close', (event, windowID) => {
const mainWindow = WindowManager.getAll('main')[0];
mainWindow.on('close', (event) => {
if (Settings.get('minToTray', true) && !global.quiting) {
mainWindow.minimize();
mainWindow.setSkipTaskbar(true);
if (process.platform !== 'darwin') {
mainWindow.minimize();
mainWindow.setSkipTaskbar(true);
} else {
mainWindow.hide();
if (app.dock && app.dock.hide) app.dock.hide();
}
event.preventDefault();
return;
}

9
src/main/features/core/tray.js

@ -17,7 +17,13 @@ appIcon = new Tray(path.resolve(`${__dirname}/../../../assets/img/main_tray.png`
const setContextMenu = () => {
const contextMenu = Menu.buildFromTemplate([
{ label: 'Show', click: () => { mainWindow.setSkipTaskbar(false); mainWindow.show(); } },
{ label: 'Show',
click: () => {
mainWindow.setSkipTaskbar(false);
mainWindow.show();
if (app.dock && app.dock.show) app.dock.show();
},
},
{
label: 'Audio Device',
submenu: audioDeviceMenu,
@ -34,6 +40,7 @@ appIcon.setToolTip('Google Play Music');
appIcon.on('double-click', () => {
mainWindow.setSkipTaskbar(false);
mainWindow.show();
if (app.dock && app.dock.show) app.dock.show();
});
// DEV: Keep the icon in the global scope or it gets garbage collected........

Loading…
Cancel
Save