aboutsummaryrefslogtreecommitdiff
path: root/src/services/chat_utils/chat_utils.js
diff options
context:
space:
mode:
authoreugenijm <eugenijm@protonmail.com>2020-07-13 00:06:45 +0300
committereugenijm <eugenijm@protonmail.com>2020-07-13 06:27:51 +0300
commit2c35afeebf4e508fd911a90d3c4af3a75e4484ab (patch)
treee63cfc5c4010a76b6c883be5fe0050a7bb7b985b /src/services/chat_utils/chat_utils.js
parent3e09a708f600b47dde831eeddb412828b38a0cf4 (diff)
Add desktop chat notifications
Diffstat (limited to 'src/services/chat_utils/chat_utils.js')
-rw-r--r--src/services/chat_utils/chat_utils.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/services/chat_utils/chat_utils.js b/src/services/chat_utils/chat_utils.js
new file mode 100644
index 00000000..7264ebcc
--- /dev/null
+++ b/src/services/chat_utils/chat_utils.js
@@ -0,0 +1,18 @@
+import { showDesktopNotification } from '../desktop_notification_utils/desktop_notification_utils.js'
+
+export const maybeShowChatNotification = (store, chat) => {
+ if (!chat.lastMessage) return
+
+ const opts = {
+ tag: chat.lastMessage.id,
+ title: chat.account.name,
+ icon: chat.account.profile_image_url,
+ body: chat.lastMessage.content
+ }
+
+ if (chat.lastMessage.attachment && chat.lastMessage.attachment.type === 'image') {
+ opts.image = chat.lastMessage.attachment.preview_url
+ }
+
+ showDesktopNotification(store.rootState, opts)
+}