Rearrange directories
This commit is contained in:
60
src/browser/webview/mattermost.js
Normal file
60
src/browser/webview/mattermost.js
Normal file
@@ -0,0 +1,60 @@
|
||||
'use strict';
|
||||
|
||||
const electron = require('electron');
|
||||
const ipc = electron.ipcRenderer;
|
||||
const NativeNotification = Notification;
|
||||
|
||||
ipc.on('retrieveUnreadCount', function() {
|
||||
var unreadCount = document.getElementsByClassName('unread-title').length;
|
||||
ipc.sendToHost('retrieveUnreadCount', unreadCount);
|
||||
});
|
||||
|
||||
// On Windows 8.1 and Windows 8, a shortcut with a Application User Model ID must be installed to the Start screen.
|
||||
// In current version, use tray balloon for notification
|
||||
function isLowerThanOrEqualWindows8_1() {
|
||||
if (process.platform != 'win32') {
|
||||
return false;
|
||||
}
|
||||
var osVersion = require('../common/osVersion');
|
||||
return (osVersion.major <= 6 && osVersion.minor <= 3);
|
||||
};
|
||||
|
||||
// Show balloon when notified.
|
||||
function overrideNotificationWithBalloon() {
|
||||
Notification = function(title, options) {
|
||||
ipc.send('notified', {
|
||||
title: title,
|
||||
options: options
|
||||
});
|
||||
};
|
||||
Notification.requestPermission = function(callback) {
|
||||
callback('granted');
|
||||
};
|
||||
Notification.prototype.close = function() {};
|
||||
};
|
||||
|
||||
// Show window even if it is hidden/minimized when notification is clicked.
|
||||
function overrideNotification() {
|
||||
Notification = function(title, options) {
|
||||
this.notification = new NativeNotification(title, options);
|
||||
};
|
||||
Notification.requestPermission = function(callback) {
|
||||
callback('granted');
|
||||
};
|
||||
Notification.prototype.close = function() {
|
||||
this.notification.close();
|
||||
};
|
||||
Notification.prototype.__defineSetter__('onclick', function(callback) {
|
||||
this.notification.onclick = function() {
|
||||
electron.remote.getCurrentWindow().show();
|
||||
callback();
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
if (process.platform === 'win32' && isLowerThanOrEqualWindows8_1()) {
|
||||
overrideNotificationWithBalloon();
|
||||
}
|
||||
else {
|
||||
overrideNotification();
|
||||
}
|
Reference in New Issue
Block a user