aboutsummaryrefslogtreecommitdiff
path: root/src/services/chat_utils/chat_utils.js
blob: 7264ebcc29ff75e722593ab851639e4b664fb955 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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)
}