From f9632497a4ae7dc85a04274b2794ef8a52e99cb3 Mon Sep 17 00:00:00 2001 From: Corey Hulen Date: Tue, 22 Aug 2017 15:10:31 -0700 Subject: Fixing logging errors for Franz (#7273) --- webapp/utils/utils.jsx | 50 ++++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/webapp/utils/utils.jsx b/webapp/utils/utils.jsx index 0424792ad..2df4a753e 100644 --- a/webapp/utils/utils.jsx +++ b/webapp/utils/utils.jsx @@ -122,33 +122,35 @@ export function notifyMe(title, body, channel, teamId, duration, silent) { if (Notification.permission === 'granted' || (Notification.permission === 'default' && !requestedNotificationPermission)) { requestedNotificationPermission = true; - Notification.requestPermission((permission) => { - if (permission === 'granted') { - try { - var notification = new Notification(title, {body, tag: body, icon: icon50, requireInteraction: notificationDuration === 0, silent}); - notification.onclick = () => { - window.focus(); - if (channel && (channel.type === Constants.DM_CHANNEL || channel.type === Constants.GM_CHANNEL)) { - browserHistory.push(TeamStore.getCurrentTeamUrl() + '/channels/' + channel.name); - } else if (channel) { - browserHistory.push(TeamStore.getTeamUrl(teamId) + '/channels/' + channel.name); - } else if (teamId) { - browserHistory.push(TeamStore.getTeamUrl(teamId) + '/channels/town-square'); - } else { - browserHistory.push(TeamStore.getCurrentTeamUrl() + '/channels/town-square'); + if (typeof Notification.requestPermission === 'function') { + Notification.requestPermission((permission) => { + if (permission === 'granted') { + try { + var notification = new Notification(title, {body, tag: body, icon: icon50, requireInteraction: notificationDuration === 0, silent}); + notification.onclick = () => { + window.focus(); + if (channel && (channel.type === Constants.DM_CHANNEL || channel.type === Constants.GM_CHANNEL)) { + browserHistory.push(TeamStore.getCurrentTeamUrl() + '/channels/' + channel.name); + } else if (channel) { + browserHistory.push(TeamStore.getTeamUrl(teamId) + '/channels/' + channel.name); + } else if (teamId) { + browserHistory.push(TeamStore.getTeamUrl(teamId) + '/channels/town-square'); + } else { + browserHistory.push(TeamStore.getCurrentTeamUrl() + '/channels/town-square'); + } + }; + + if (notificationDuration > 0) { + setTimeout(() => { + notification.close(); + }, notificationDuration); } - }; - - if (notificationDuration > 0) { - setTimeout(() => { - notification.close(); - }, notificationDuration); + } catch (e) { + console.error(e); //eslint-disable-line no-console } - } catch (e) { - console.error(e); //eslint-disable-line no-console } - } - }); + }); + } } } -- cgit v1.2.3-1-g7c22