From 0a2146692c1c53eb75e4b561d66be30aa5819857 Mon Sep 17 00:00:00 2001 From: Yuya Ochiai Date: Wed, 12 Oct 2016 22:36:06 +0900 Subject: 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. --- webapp/utils/user_agent.jsx | 16 +++++++++++++++- webapp/utils/utils.jsx | 4 ++-- 2 files changed, 17 insertions(+), 3 deletions(-) (limited to 'webapp/utils') 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) { -- cgit v1.2.3-1-g7c22