Skip to content

Commit 9d19829

Browse files
committed
Notification window new implementation.
- Fix window/app action buttons - Improve webpack config
1 parent 3a411e6 commit 9d19829

File tree

8 files changed

+137
-50
lines changed

8 files changed

+137
-50
lines changed

.babelrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
presets: [
3+
'es2015',
4+
'stage-0',
5+
'react'
6+
]
7+
}

app/public/js/common/playerService.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,11 @@ app.factory('playerService', function (
159159
if (window.localStorage.notificationToggle === "true") {
160160
songNotification = new Notification(songNotificationTitle, {
161161
body: trackObj.songUser,
162-
icon: trackObj.songThumbnail
162+
icon: trackObj.songThumbnail,
163+
silent: true
163164
});
164165
songNotification.onclick = function () {
165-
// gui.Window.get().show();
166+
ipcRenderer.send('showApp');
166167
};
167168
}
168169

app/public/js/components/header/headerActions.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
const guiConfig = require('../../system/guiConfig').guiConfig;
12
import React, { Component } from 'react';
23

34
class BackForwardActions extends Component {
@@ -16,7 +17,6 @@ class BackForwardActions extends Component {
1617
}
1718

1819
class WindowActions extends Component {
19-
2020
closeApp() {
2121
guiConfig.close();
2222
}

main.js

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ const {
44
app,
55
BrowserWindow,
66
ipcMain,
7-
ipcRenderer,
87
globalShortcut
98
} = require('electron');
109
const windowStateKeeper = require('electron-window-state');
@@ -50,27 +49,31 @@ app.on('ready', () => {
5049
initializeMediaShortcuts();
5150
});
5251

52+
app.on('will-quit', () => {
53+
// Unregister all shortcuts.
54+
globalShortcut.unregisterAll()
55+
})
56+
5357
app.on('activate', () => {
54-
mainWindow.show();
55-
mainWindow.focus();
58+
showAndFocus();
5659
});
5760

5861
/**
5962
* Receive maximize event and trigger command
6063
*/
6164
ipcMain.on('maximizeApp', () => {
62-
mainWindow.maximize();
65+
if (mainWindow.isMaximized()) {
66+
mainWindow.unmaximize();
67+
} else {
68+
mainWindow.maximize();
69+
}
6370
});
6471

6572
/**
6673
* Receive minimize event and trigger command
6774
*/
6875
ipcMain.on('minimizeApp', () => {
69-
if (mainWindow.isMaximized()) {
70-
mainWindow.unmaximize();
71-
} else {
72-
mainWindow.maximize();
73-
}
76+
mainWindow.minimize()
7477
});
7578

7679
/**
@@ -80,6 +83,10 @@ ipcMain.on('hideApp', () => {
8083
mainWindow.hide();
8184
});
8285

86+
ipcMain.on('showApp', () => {
87+
showAndFocus();
88+
});
89+
8390
/**
8491
* Receive close event and trigger command
8592
*/
@@ -91,6 +98,11 @@ ipcMain.on('closeApp', () => {
9198
}
9299
});
93100

101+
function showAndFocus() {
102+
mainWindow.show();
103+
mainWindow.focus();
104+
}
105+
94106
function initializeMediaShortcuts() {
95107
globalShortcut.register('MediaPlayPause', () => {
96108
mainWindow.webContents.send('MediaPlayPause');

package.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
"start": "electron .",
88
"build": "npm run webpack:prod && npm run sass:prod && npm run package:osx",
99
"watch": "npm run webpack:dev & npm run sass:dev",
10-
"webpack:prod": "./node_modules/.bin/webpack -p --config ./webpack.config.js",
11-
"webpack:dev": "./node_modules/.bin/webpack -d --watch --config ./webpack.config.js",
10+
"webpack:prod": "./node_modules/.bin/webpack -p --config ./webpack.prod.js",
11+
"webpack:dev": "./node_modules/.bin/webpack -d --watch --config ./webpack.dev.js",
1212
"sass:prod": "./node_modules/.bin/node-sass --include-path ./app/public/stylesheets/sass --output-style compressed ./app/public/stylesheets/sass/app.scss ./app/public/stylesheets/css/app.css",
1313
"sass:dev": "./node_modules/.bin/node-sass --recursive --include-path ./app/public/stylesheets/sass --output-style expanded ./app/public/stylesheets/sass/app.scss ./app/public/stylesheets/css/app.css",
1414
"package:osx": "electron-packager ./ Soundnode --platform=darwin --out ./dist/Soundnode --version 1.4.4 --overwrite --icon ./app/public/soundnode.ico",
@@ -19,11 +19,12 @@
1919
"author": "Michael Lancaster",
2020
"license": "GNU",
2121
"devDependencies": {
22-
"babel-core": "^6.0.14",
23-
"babel-loader": "^6.0.0",
24-
"babel-preset-es2015": "^6.0.15",
25-
"babel-preset-react": "^6.0.15",
26-
"babel-preset-stage-0": "^6.0.15",
22+
"babel-core": "^6.3.26",
23+
"babel-loader": "^6.2.1",
24+
"babel-preset-es2015": "^6.3.13",
25+
"babel-preset-react": "^6.3.13",
26+
"babel-preset-stage-0": "^6.3.13",
27+
"babel-register": "^6.3.13",
2728
"electron-packager": "^8.1.0",
2829
"electron-prebuilt": "^1.4.3",
2930
"eslint": "^1.8.0",

webpack.config.js

Lines changed: 0 additions & 31 deletions
This file was deleted.

webpack.dev.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
'use strict';
2+
3+
const path = require('path');
4+
const webpack = require('webpack');
5+
6+
module.exports = {
7+
devtool: 'eval',
8+
entry: path.join(__dirname, './app/public/js/components/main.jsx'),
9+
output: {
10+
path: path.join(__dirname, './app/dist'),
11+
filename: 'bundle.js',
12+
publicPath: '/'
13+
},
14+
module: {
15+
loaders: [
16+
{
17+
test: /\.(js|jsx)$/,
18+
exclude: /node_modules/,
19+
loader: 'babel-loader'
20+
}
21+
]
22+
},
23+
resolve: {
24+
extensions: ['', '.js', '.jsx'],
25+
modulesDirectories: ['node_modules', 'components', 'vendors']
26+
},
27+
plugins: [
28+
new webpack.optimize.DedupePlugin(),
29+
new webpack.optimize.OccurenceOrderPlugin(),
30+
new webpack.NoErrorsPlugin(),
31+
new webpack.DefinePlugin({
32+
'process.env.NODE_ENV': '"development"'
33+
})
34+
],
35+
externals: [
36+
(function () {
37+
const IGNORES = [
38+
'electron'
39+
];
40+
return function (context, request, callback) {
41+
if (IGNORES.indexOf(request) >= 0) {
42+
return callback(null, "require('" + request + "')");
43+
}
44+
return callback();
45+
};
46+
})()
47+
]
48+
};

webpack.prod.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
'use strict';
2+
3+
const path = require('path');
4+
const webpack = require('webpack');
5+
6+
module.exports = {
7+
devtool: 'source-map',
8+
entry: path.join(__dirname, './app/public/js/components/main.jsx'),
9+
output: {
10+
path: path.join(__dirname, './app/dist'),
11+
filename: 'bundle.js',
12+
publicPath: '/'
13+
},
14+
module: {
15+
loaders: [
16+
{
17+
test: /\.(js|jsx)$/,
18+
exclude: /node_modules/,
19+
loader: 'babel-loader'
20+
}
21+
]
22+
},
23+
resolve: {
24+
extensions: ['', '.js', '.jsx'],
25+
modulesDirectories: ['node_modules', 'components', 'vendors']
26+
},
27+
plugins: [
28+
new webpack.optimize.DedupePlugin(),
29+
new webpack.optimize.OccurenceOrderPlugin(),
30+
new webpack.optimize.UglifyJsPlugin({ compress: { warnings: false } }),
31+
new webpack.NoErrorsPlugin(),
32+
new webpack.DefinePlugin({
33+
'process.env.NODE_ENV': '"production"'
34+
})
35+
],
36+
externals: [
37+
(function () {
38+
const IGNORES = [
39+
'electron'
40+
];
41+
return function (context, request, callback) {
42+
if (IGNORES.indexOf(request) >= 0) {
43+
return callback(null, "require('" + request + "')");
44+
}
45+
return callback();
46+
};
47+
})()
48+
]
49+
};

0 commit comments

Comments
 (0)