From 9d4db14fc3f367966f9d3d295c3ad5391c50284d Mon Sep 17 00:00:00 2001 From: "Stanko K.R." Date: Tue, 17 Feb 2026 13:57:24 +0100 Subject: [PATCH] Reinstate card readings --- app/controllers/cards/readings_controller.rb | 4 ++-- app/models/card/readable.rb | 4 ++-- app/views/cards/readings/create.turbo_stream.erb | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 app/views/cards/readings/create.turbo_stream.erb diff --git a/app/controllers/cards/readings_controller.rb b/app/controllers/cards/readings_controller.rb index 1fc675b84..75fdbac19 100644 --- a/app/controllers/cards/readings_controller.rb +++ b/app/controllers/cards/readings_controller.rb @@ -2,12 +2,12 @@ class Cards::ReadingsController < ApplicationController include CardScoped def create - @card.read_by(Current.user) + @notification = @card.read_by(Current.user) record_board_access end def destroy - @card.unread_by(Current.user) + @notification = @card.unread_by(Current.user) record_board_access end diff --git a/app/models/card/readable.rb b/app/models/card/readable.rb index 0168f00a9..aec8c18dd 100644 --- a/app/models/card/readable.rb +++ b/app/models/card/readable.rb @@ -2,11 +2,11 @@ module Card::Readable extend ActiveSupport::Concern def read_by(user) - user.notifications.find_by(card: self)&.read + user.notifications.find_by(card: self)&.tap(&:read) end def unread_by(user) - user.notifications.find_by(card: self)&.unread + user.notifications.find_by(card: self)&.tap(&:unread) end def remove_inaccessible_notifications diff --git a/app/views/cards/readings/create.turbo_stream.erb b/app/views/cards/readings/create.turbo_stream.erb new file mode 100644 index 000000000..ebfcee900 --- /dev/null +++ b/app/views/cards/readings/create.turbo_stream.erb @@ -0,0 +1 @@ +<%= turbo_stream.remove @notification if @notification %>