Just open one turbo stream per card
Per comment is excessive and needless
This commit is contained in:
@@ -34,11 +34,11 @@ class Cards::Comments::ReactionsController < ApplicationController
|
||||
end
|
||||
|
||||
def broadcast_create(reaction)
|
||||
reaction.broadcast_append_to @comment, :reactions,
|
||||
reaction.broadcast_append_to @card,
|
||||
target: "reactions_comment_#{@comment.id}", partial: "cards/comments/reactions/reaction", locals: { comment: @comment }
|
||||
end
|
||||
|
||||
def broadcast_remove(reaction)
|
||||
reaction.broadcast_remove_to @comment, :reactions
|
||||
reaction.broadcast_remove_to @card
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
<%= turbo_frame_tag comment, :reacting do %>
|
||||
<%= turbo_stream_from comment, :reactions %>
|
||||
|
||||
<div class="reactions flex flex-wrap align-center gap full-width">
|
||||
<div class="flex-inline flex-wrap gap" id="<%= dom_id(comment, :reactions) %>" data-turbo-streaming-target="container">
|
||||
<%= render partial: "cards/comments/reactions/reaction", collection: comment.reactions.ordered, locals: { comment: comment }, cached: true %>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<% @page_title = card_title(@card) %>
|
||||
<%= turbo_stream_from @card %>
|
||||
|
||||
<% content_for :header do %>
|
||||
<% if @card.creating? && @card.can_recover_abandoned_creation? %>
|
||||
|
||||
@@ -4,10 +4,11 @@ class Cards::Comments::ReactionsControllerTest < ActionDispatch::IntegrationTest
|
||||
setup do
|
||||
sign_in_as :jz
|
||||
@comment = comments(:logo_agreement_jz)
|
||||
@card = @comment.card
|
||||
end
|
||||
|
||||
test "create" do
|
||||
assert_turbo_stream_broadcasts [ @comment, :reactions ], count: 1 do
|
||||
assert_turbo_stream_broadcasts @card, count: 1 do
|
||||
assert_difference -> { @comment.reactions.count }, 1 do
|
||||
post card_comment_reactions_url(@comment.card, @comment, format: :turbo_stream), params: { reaction: { content: "Great work!" } }
|
||||
assert_redirected_to card_comment_reactions_url(@comment.card, @comment)
|
||||
@@ -16,7 +17,7 @@ class Cards::Comments::ReactionsControllerTest < ActionDispatch::IntegrationTest
|
||||
end
|
||||
|
||||
test "destroy" do
|
||||
assert_turbo_stream_broadcasts [ @comment, :reactions ], count: 1 do
|
||||
assert_turbo_stream_broadcasts @card, count: 1 do
|
||||
assert_difference -> { @comment.reactions.count }, -1 do
|
||||
delete card_comment_reaction_url(@comment.card, @comment, reactions(:kevin), format: :turbo_stream)
|
||||
assert_response :success
|
||||
|
||||
Reference in New Issue
Block a user