summaryrefslogtreecommitdiffstats
path: root/webapp
diff options
context:
space:
mode:
authorYuya Ochiai <yuya0321@gmail.com>2016-10-12 22:36:06 +0900
committerHarrison Healey <harrisonmhealey@gmail.com>2016-10-12 09:36:06 -0400
commit0a2146692c1c53eb75e4b561d66be30aa5819857 (patch)
treec651722bd2d12ad988b059da20912aba016f70e7 /webapp
parent552508706d5ec4b87e67c0bf46609fb320ee7792 (diff)
downloadchat-0a2146692c1c53eb75e4b561d66be30aa5819857.tar.gz
chat-0a2146692c1c53eb75e4b561d66be30aa5819857.tar.bz2
chat-0a2146692c1c53eb75e4b561d66be30aa5819857.zip
PLT-4261 Set silent parameter for Notification (#4192)
In the desktop app, there are two kinds of sound on notifications, `Utils.ding()` and `new Notification()` on Windows and Mac. This commit stops both if the account setting is set to off.
Diffstat (limited to 'webapp')
-rw-r--r--webapp/stores/notification_store.jsx6
-rw-r--r--webapp/utils/user_agent.jsx16
-rw-r--r--webapp/utils/utils.jsx4
3 files changed, 21 insertions, 5 deletions
diff --git a/webapp/stores/notification_store.jsx b/webapp/stores/notification_store.jsx
index 917b86df8..02826d586 100644
--- a/webapp/stores/notification_store.jsx
+++ b/webapp/stores/notification_store.jsx
@@ -7,6 +7,7 @@ import Constants from 'utils/constants.jsx';
import UserStore from './user_store.jsx';
import ChannelStore from './channel_store.jsx';
import PreferenceStore from './preference_store.jsx';
+import * as UserAgent from 'utils/user_agent.jsx';
import * as Utils from 'utils/utils.jsx';
import * as PostUtils from 'utils/post_utils.jsx';
const ActionTypes = Constants.ActionTypes;
@@ -97,9 +98,10 @@ class NotificationStoreClass extends EventEmitter {
duration = parseInt(user.notify_props.desktop_duration, 10) * 1000;
}
- Utils.notifyMe(title, body, channel, teamId, duration);
+ const sound = !user.notify_props || user.notify_props.desktop_sound === 'true';
+ Utils.notifyMe(title, body, channel, teamId, duration, !sound);
- if (!user.notify_props || user.notify_props.desktop_sound === 'true') {
+ if (sound && !UserAgent.isWindowsApp() && !UserAgent.isMacApp()) {
Utils.ding();
}
}
diff --git a/webapp/utils/user_agent.jsx b/webapp/utils/user_agent.jsx
index cece453ce..f64ea193c 100644
--- a/webapp/utils/user_agent.jsx
+++ b/webapp/utils/user_agent.jsx
@@ -20,6 +20,8 @@ Edge:
Desktop App:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Mattermost/1.2.1 Chrome/49.0.2623.75 Electron/0.37.8 Safari/537.36
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586
+ Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_0) AppleWebKit/537.36 (KHTML, like Gecko) Mattermost/3.4.1 Chrome/53.0.2785.113 Electron/1.4.2 Safari/537.36
+ Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Mattermost/3.4.1 Chrome/51.0.2704.106 Electron/1.2.8 Safari/537.36
Android Chrome:
Mozilla/5.0 (Linux; Android 4.0.4; Galaxy Nexus Build/IMM76B) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.133 Mobile Safari/535.19
@@ -98,4 +100,16 @@ export function isInternetExplorer() {
export function isEdge() {
return userAgent.indexOf('Edge') !== -1;
-} \ No newline at end of file
+}
+
+export function isDesktopApp() {
+ return userAgent.indexOf('Mattermost') !== -1 && userAgent.indexOf('Electron') !== -1;
+}
+
+export function isWindowsApp() {
+ return isDesktopApp() && userAgent.indexOf('Windows') !== -1;
+}
+
+export function isMacApp() {
+ return isDesktopApp() && userAgent.indexOf('Macintosh') !== -1;
+}
diff --git a/webapp/utils/utils.jsx b/webapp/utils/utils.jsx
index 73765495c..80f704e69 100644
--- a/webapp/utils/utils.jsx
+++ b/webapp/utils/utils.jsx
@@ -86,7 +86,7 @@ export function getCookie(name) {
var requestedNotificationPermission = false;
-export function notifyMe(title, body, channel, teamId, duration) {
+export function notifyMe(title, body, channel, teamId, duration, silent) {
if (!('Notification' in window)) {
return;
}
@@ -102,7 +102,7 @@ export function notifyMe(title, body, channel, teamId, duration) {
Notification.requestPermission((permission) => {
if (permission === 'granted') {
try {
- var notification = new Notification(title, {body, tag: body, icon: icon50, requireInteraction: notificationDuration === 0});
+ var notification = new Notification(title, {body, tag: body, icon: icon50, requireInteraction: notificationDuration === 0, silent});
notification.onclick = () => {
window.focus();
if (channel) {