Add support for sound notifications on Windows 7 and 8
ding.mp3 is derived from /platform repository.
This commit is contained in:
parent
366c73b164
commit
2fa618c9c9
|
@ -15,6 +15,7 @@ Release date: TBD
|
|||
|
||||
#### Windows
|
||||
- Removed Japanese fonts support it's no longer necessary.
|
||||
- Added support for sound notifications on Windows 7 and 8.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
"mocha-circleci-reporter": "0.0.2",
|
||||
"npm-run-all": "^4.0.2",
|
||||
"spectron": "~3.6.0",
|
||||
"url-loader": "^0.5.8",
|
||||
"webpack": "^2.2.1",
|
||||
"webpack-dev-server": "^2.4.1",
|
||||
"webpack-merge": "^3.0.0"
|
||||
|
|
BIN
src/assets/ding.mp3
Normal file
BIN
src/assets/ding.mp3
Normal file
Binary file not shown.
|
@ -2,9 +2,17 @@
|
|||
|
||||
const OriginalNotification = Notification;
|
||||
const {remote} = require('electron');
|
||||
const {throttle} = require('underscore');
|
||||
const osVersion = require('../../common/osVersion');
|
||||
const dingDataURL = require('../../assets/ding.mp3'); // https://github.com/mattermost/platform/blob/v3.7.3/webapp/images/ding.mp3
|
||||
|
||||
const appIconURL = `file:///${remote.app.getAppPath()}/assets/appicon.png`;
|
||||
|
||||
const playDing = throttle(() => {
|
||||
const ding = new Audio(dingDataURL);
|
||||
ding.play();
|
||||
}, 3000, {trailing: false});
|
||||
|
||||
function override(eventHandlers) {
|
||||
Notification = function constructor(title, options) { // eslint-disable-line no-global-assign, no-native-reassign
|
||||
if (process.platform === 'win32') {
|
||||
|
@ -18,6 +26,12 @@ function override(eventHandlers) {
|
|||
if (eventHandlers.notification) {
|
||||
eventHandlers.notification(title, options);
|
||||
}
|
||||
|
||||
if (process.platform === 'win32' && osVersion.isLowerThanOrEqualWindows8_1()) {
|
||||
if (!options.silent) {
|
||||
playDing();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// static properties
|
||||
|
|
|
@ -25,6 +25,11 @@ module.exports = merge(base, {
|
|||
plugins: ['transform-object-rest-spread']
|
||||
}
|
||||
}
|
||||
}, {
|
||||
test: /\.mp3$/,
|
||||
use: {
|
||||
loader: 'url-loader'
|
||||
}
|
||||
}]
|
||||
},
|
||||
node: {
|
||||
|
|
Loading…
Reference in a new issue