fix: Unread notification count in multiple accounts (#4373)
Fixes: #4367
This commit is contained in:
parent
3509692055
commit
1dd0c7249c
2 changed files with 6 additions and 5 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue