Add support for sound notifications on Windows 7 and 8

ding.mp3 is derived from /platform repository.
This commit is contained in:
Yuya Ochiai
2017-04-01 01:12:04 +09:00
parent 366c73b164
commit 2fa618c9c9
5 changed files with 21 additions and 0 deletions

View File

@@ -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