mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 12:08:01 +00:00
fix: Unread notification count in multiple accounts (#4373)
Fixes: #4367
This commit is contained in:
@@ -8,8 +8,9 @@ class BaseListener
|
||||
|
||||
def extract_notification_and_account(event)
|
||||
notification = event.data[:notification]
|
||||
unread_count = notification.user.notifications_meta[:unread_count]
|
||||
count = notification.user.notifications_meta[:count]
|
||||
notifications_meta = notification.user.notifications_meta(notification.account_id)
|
||||
unread_count = notifications_meta[:unread_count]
|
||||
count = notifications_meta[:count]
|
||||
[notification, notification.account, unread_count, count]
|
||||
end
|
||||
|
||||
|
||||
@@ -188,10 +188,10 @@ class User < ApplicationRecord
|
||||
mutations_from_database.changed?('email')
|
||||
end
|
||||
|
||||
def notifications_meta
|
||||
def notifications_meta(account_id)
|
||||
{
|
||||
unread_count: notifications.where(read_at: nil).count,
|
||||
count: notifications.count
|
||||
unread_count: notifications.where(account_id: account_id, read_at: nil).count,
|
||||
count: notifications.where(account_id: account_id).count
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user