Broadcast notification readings
so that the notification tray will be more consistent across open browser tabs.
This commit is contained in:
@@ -17,6 +17,7 @@ class Notification < ApplicationRecord
|
||||
|
||||
def read
|
||||
update!(read_at: Time.current)
|
||||
broadcast_read
|
||||
end
|
||||
|
||||
def read?
|
||||
@@ -27,4 +28,8 @@ class Notification < ApplicationRecord
|
||||
def broadcast_unread
|
||||
broadcast_prepend_later_to user, :notifications, target: "notifications"
|
||||
end
|
||||
|
||||
def broadcast_read
|
||||
broadcast_remove_to user, :notifications
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user