From 9e8a943ec70fe31a1b7bb55ddf9f9084ddd0f245 Mon Sep 17 00:00:00 2001 From: Nithin David Thomas Date: Thu, 4 Mar 2021 19:24:03 +0530 Subject: [PATCH] feat: Add audio alert for incoming messages on dashboard (#1738) Fixes: #1345 --- .../dashboard/helper/actionCable.js | 2 + .../dashboard/i18n/locale/en/settings.json | 5 ++ .../settings/profile/NotificationSettings.vue | 46 ++++++++++++- app/javascript/packs/application.js | 3 +- .../shared/helpers/AudioNotificationHelper.js | 62 +++++++++++++++++- public/dashboard/audios/ding.mp3 | Bin 0 -> 2667 bytes 6 files changed, 115 insertions(+), 3 deletions(-) create mode 100644 public/dashboard/audios/ding.mp3 diff --git a/app/javascript/dashboard/helper/actionCable.js b/app/javascript/dashboard/helper/actionCable.js index 1fb9961dc..9bed8e7d5 100644 --- a/app/javascript/dashboard/helper/actionCable.js +++ b/app/javascript/dashboard/helper/actionCable.js @@ -1,5 +1,6 @@ import AuthAPI from '../api/auth'; import BaseActionCableConnector from '../../shared/helpers/BaseActionCableConnector'; +import { newMessageNotification } from 'shared/helpers/AudioNotificationHelper'; class ActionCableConnector extends BaseActionCableConnector { constructor(app, pubsubToken) { @@ -63,6 +64,7 @@ class ActionCableConnector extends BaseActionCableConnector { onLogout = () => AuthAPI.logout(); onMessageCreated = data => { + newMessageNotification(data); this.app.$store.dispatch('addMessage', data); }; diff --git a/app/javascript/dashboard/i18n/locale/en/settings.json b/app/javascript/dashboard/i18n/locale/en/settings.json index 6b42cf3f2..fd915fb0c 100644 --- a/app/javascript/dashboard/i18n/locale/en/settings.json +++ b/app/javascript/dashboard/i18n/locale/en/settings.json @@ -22,6 +22,11 @@ "TITLE": "Access Token", "NOTE": "This token can be used if you are building an API based integration" }, + "AUDIO_NOTIFICATIONS_SECTION": { + "TITLE": "Audio Notifications", + "NOTE": "Enable audio notifications in dashboard for new messages and conversations.", + "ENABLE_AUDIO": "Play audio notification when a new conversation is created or new messages arrives" + }, "EMAIL_NOTIFICATIONS_SECTION": { "TITLE": "Email Notifications", "NOTE": "Update your email notification preferences here", diff --git a/app/javascript/dashboard/routes/dashboard/settings/profile/NotificationSettings.vue b/app/javascript/dashboard/routes/dashboard/settings/profile/NotificationSettings.vue index a2d6bf215..38bf2744e 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/profile/NotificationSettings.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/profile/NotificationSettings.vue @@ -1,5 +1,33 @@