From a76db5b84f661f1254da6d04af5100f858051bb4 Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Mon, 29 Aug 2016 09:52:59 -0400 Subject: PLT-2074 Refactor desktop notification settings UI and add setting for duration (#3883) * Refactor desktop notification settings UI and add setting for duration * Update en.json * Update desktop_notification_settings.jsx --- webapp/stores/notification_store.jsx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'webapp/stores') diff --git a/webapp/stores/notification_store.jsx b/webapp/stores/notification_store.jsx index 507954a10..c5122dd7a 100644 --- a/webapp/stores/notification_store.jsx +++ b/webapp/stores/notification_store.jsx @@ -79,17 +79,26 @@ class NotificationStoreClass extends EventEmitter { notifyText = notifyText.substring(0, 49) + '...'; } + let body = ''; if (notifyText.length === 0) { if (msgProps.image) { - Utils.notifyMe(title, username + Utils.localizeMessage('channel_loader.uploadedImage', ' uploaded an image'), channel, teamId); + body = username + Utils.localizeMessage('channel_loader.uploadedImage', ' uploaded an image'); } else if (msgProps.otherFile) { - Utils.notifyMe(title, username + Utils.localizeMessage('channel_loader.uploadedFile', ' uploaded a file'), channel, teamId); + body = Utils.localizeMessage('channel_loader.uploadedFile', ' uploaded a file'); } else { - Utils.notifyMe(title, username + Utils.localizeMessage('channel_loader.something', ' did something new'), channel, teamId); + body = username + Utils.localizeMessage('channel_loader.something', ' did something new'); } } else { - Utils.notifyMe(title, username + Utils.localizeMessage('channel_loader.wrote', ' wrote: ') + notifyText, channel, teamId); + body = username + Utils.localizeMessage('channel_loader.wrote', ' wrote: ') + notifyText; } + + let duration = Constants.DEFAULT_NOTIFICATION_DURATION; + if (user.notify_props && user.notify_props.desktop_duration) { + duration = parseInt(user.notify_props.desktop_duration, 10) * 1000; + } + + Utils.notifyMe(title, body, channel, teamId, duration); + if (!user.notify_props || user.notify_props.desktop_sound === 'true') { Utils.ding(); } -- cgit v1.2.3-1-g7c22