fix chat periodic notification

This commit is contained in:
Henry Jameson 2026-08-26 17:50:14 +03:00
commit a4b02936ac

View file

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