From 38116f64e418d8600f915026a1485f506bb81c89 Mon Sep 17 00:00:00 2001 From: Jorge Manrubia Date: Mon, 6 Oct 2025 10:43:46 +0200 Subject: [PATCH] Higher fidelity for watching/unwatching cards --- app/controllers/cards/watches_controller.rb | 2 -- app/views/cards/_messages.html.erb | 14 +------------- app/views/cards/comments/_watchers.html.erb | 13 +++++++++++++ app/views/cards/watches/_refresh.turbo_stream.erb | 7 +++++++ app/views/cards/watches/_watch_button.html.erb | 13 +++++++++++++ app/views/cards/watches/create.turbo_stream.erb | 1 + app/views/cards/watches/destroy.turbo_stream.erb | 1 + app/views/cards/watches/show.html.erb | 12 +----------- test/controllers/cards/watches_controller_test.rb | 4 ---- 9 files changed, 37 insertions(+), 30 deletions(-) create mode 100644 app/views/cards/comments/_watchers.html.erb create mode 100644 app/views/cards/watches/_refresh.turbo_stream.erb create mode 100644 app/views/cards/watches/_watch_button.html.erb create mode 100644 app/views/cards/watches/create.turbo_stream.erb create mode 100644 app/views/cards/watches/destroy.turbo_stream.erb diff --git a/app/controllers/cards/watches_controller.rb b/app/controllers/cards/watches_controller.rb index 7556e2000..7308c2279 100644 --- a/app/controllers/cards/watches_controller.rb +++ b/app/controllers/cards/watches_controller.rb @@ -3,11 +3,9 @@ class Cards::WatchesController < ApplicationController def create @card.watch_by Current.user - redirect_back_or_to @card end def destroy @card.unwatch_by Current.user - redirect_back_or_to @card end end diff --git a/app/views/cards/_messages.html.erb b/app/views/cards/_messages.html.erb index f6ab5a37d..144be94cc 100644 --- a/app/views/cards/_messages.html.erb +++ b/app/views/cards/_messages.html.erb @@ -3,19 +3,7 @@ <%= render partial: "cards/comments/comment", collection: card.comments.chronologically, cached: true %> <%= render "cards/comments/new", card: card %> -
- Subscribers - -

- <%= pluralize(@card.watchers.without(User.system).count, "person") %> will be notified when someone comments on this. -

- -
- <% @card.watchers.without(User.system).alphabetically.each do |watcher| %> - <%= avatar_tag watcher %> - <% end %> -
-
+ <%= render "cards/comments/watchers", card: card %> <% end %>