diff --git a/app/controllers/readings_controller.rb b/app/controllers/readings_controller.rb index 5fc57ec9c..9c5798ed3 100644 --- a/app/controllers/readings_controller.rb +++ b/app/controllers/readings_controller.rb @@ -2,7 +2,12 @@ class ReadingsController < ApplicationController include BubbleScoped, BucketScoped def create - @notifications = Current.user.notifications.where(bubble: @bubble) - @notifications.update(read: true) + mark_bubble_notifications_read + @notifications = Current.user.notifications.unread.ordered.limit(20) end + + private + def mark_bubble_notifications_read + Current.user.notifications.where(bubble: @bubble).update(read: true) + end end diff --git a/app/views/readings/create.turbo_stream.erb b/app/views/readings/create.turbo_stream.erb index 5d7fe7801..a66c881ce 100644 --- a/app/views/readings/create.turbo_stream.erb +++ b/app/views/readings/create.turbo_stream.erb @@ -1,3 +1,3 @@ -<% @notifications.each do |notification| %> - <%= turbo_stream.remove notification %> +<%= turbo_stream.update :notifications do %> + <%= render @notifications %> <% end %>