Broadcast when all notifications are cleared

Then make the turbo response to clearing all notifications a no-op.

This has the bonus side effect of properly clearing the notifications
try on all open pages.

ref: https://fizzy.37signals.com/5986089/collections/2/cards/796
This commit is contained in:
Mike Dalessio
2025-07-03 12:05:41 -04:00
parent 19af7c7c50
commit 53ebb509d8
2 changed files with 5 additions and 2 deletions
@@ -6,6 +6,9 @@ class Notifications::ReadingsController < ApplicationController
def create_all
Current.user.notifications.unread.read_all
redirect_to notifications_path
respond_to do |format|
format.html { redirect_to notifications_path }
format.turbo_stream { } # No action needed, readings will have been broadcast
end
end
end
+1 -1
View File
@@ -13,7 +13,7 @@ class Notification < ApplicationRecord
delegate :card, to: :source
def self.read_all
update!(read_at: Time.current)
all.each { |notification| notification.read }
end
def read