Add desktop chat notifications

This commit is contained in:
eugenijm 2020-07-13 00:06:45 +03:00
parent 3e09a708f6
commit 2c35afeebf
6 changed files with 82 additions and 49 deletions

View 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)
}