From a2ae98eee8d576f87632db9839adc2faf7d59594 Mon Sep 17 00:00:00 2001 From: Georg Gadinger Date: Thu, 24 Nov 2022 08:02:42 +0100 Subject: [PATCH] inbox_controller: update all inbox entries when requesting turbo stream since there's no layout rendered which updates all inbox entries the inbox entries would still be shown as unread fixes #827 --- app/controllers/inbox_controller.rb | 6 +++++- app/views/layouts/inbox.html.haml | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/inbox_controller.rb b/app/controllers/inbox_controller.rb index c5af4593..6954b5a1 100644 --- a/app/controllers/inbox_controller.rb +++ b/app/controllers/inbox_controller.rb @@ -49,7 +49,11 @@ class InboxController < ApplicationController @disabled = true if @inbox.empty? respond_to do |format| format.html - format.turbo_stream { render "show", layout: false, status: :see_other } + format.turbo_stream do + render "show", layout: false, status: :see_other + + @inbox.update_all(new: false) + end end end diff --git a/app/views/layouts/inbox.html.haml b/app/views/layouts/inbox.html.haml index 0aff256e..e87d6cbb 100644 --- a/app/views/layouts/inbox.html.haml +++ b/app/views/layouts/inbox.html.haml @@ -8,6 +8,6 @@ = render 'shared/links' :ruby - Inbox.where(id: @inbox.ids).update_all(new: false) + @inbox.update_all(new: false) provide(:title, generate_title('Inbox')) parent_layout 'base'