Add desktop chat notifications
This commit is contained in:
parent
3e09a708f6
commit
2c35afeebf
6 changed files with 82 additions and 49 deletions
18
src/services/chat_utils/chat_utils.js
Normal file
18
src/services/chat_utils/chat_utils.js
Normal file
|
@ -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)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue