fix chat periodic notification
This commit is contained in:
parent
d9f03f61ae
commit
a4b02936ac
1 changed files with 6 additions and 0 deletions
|
|
@ -3,8 +3,13 @@ import { showDesktopNotification } from '../desktop_notification_utils/desktop_n
|
|||
import { useUsersStore } from 'src/stores/users.js'
|
||||
|
||||
export const maybeShowChatNotification = (chat) => {
|
||||
// No messages
|
||||
if (!chat.lastMessage) return
|
||||
// Already shown notification for this message
|
||||
if (chat.lastMessage.id === chat.lastNotifiedMessageId) return
|
||||
// No unreads to display
|
||||
if (chat.unread === 0) return
|
||||
// Don't notify on outgoing message (shouldn't happen with condition above)
|
||||
if (useUsersStore().currentUser.id === chat.lastMessage.account_id) return
|
||||
|
||||
const opts = {
|
||||
|
|
@ -19,6 +24,7 @@ export const maybeShowChatNotification = (chat) => {
|
|||
opts.image = chat.lastMessage.attachment.preview_url
|
||||
}
|
||||
|
||||
chat.lastNotifiedMessageId = chat.lastMessage.id
|
||||
showDesktopNotification(opts)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue