diff --git a/app/controllers/cards/comments/reactions_controller.rb b/app/controllers/cards/comments/reactions_controller.rb index 0a728fbb2..54f63dda7 100644 --- a/app/controllers/cards/comments/reactions_controller.rb +++ b/app/controllers/cards/comments/reactions_controller.rb @@ -10,29 +10,16 @@ class Cards::Comments::ReactionsController < ApplicationController end def create - reaction = @comment.reactions.create!(params.expect(reaction: :content)) - - broadcast_create(reaction) - redirect_to card_comment_reactions_path(@card, @comment) + @reaction = @comment.reactions.create!(params.expect(reaction: :content)) end def destroy - reaction = @comment.reactions.find(params[:id]) - reaction.destroy - - broadcast_remove(reaction) + @reaction = @comment.reactions.find(params[:id]) + @reaction.destroy end private def set_comment @comment = @card.comments.find(params[:comment_id]) end - - def broadcast_create(reaction) - reaction.broadcast_append_to @card, target: [ @comment, :reactions ], partial: "cards/comments/reactions/reaction" - end - - def broadcast_remove(reaction) - reaction.broadcast_remove_to @card - end end diff --git a/app/views/cards/comments/reactions/create.turbo_stream.erb b/app/views/cards/comments/reactions/create.turbo_stream.erb new file mode 100644 index 000000000..7ae1f1daa --- /dev/null +++ b/app/views/cards/comments/reactions/create.turbo_stream.erb @@ -0,0 +1 @@ +<%= turbo_stream.append([ @comment, :reactions ], partial: "cards/comments/reactions/reaction", locals: { reaction: @reaction }) %> diff --git a/app/views/cards/comments/reactions/destroy.turbo_stream.erb b/app/views/cards/comments/reactions/destroy.turbo_stream.erb new file mode 100644 index 000000000..936436e11 --- /dev/null +++ b/app/views/cards/comments/reactions/destroy.turbo_stream.erb @@ -0,0 +1 @@ +<%= turbo_stream.remove @reaction %> diff --git a/app/views/cards/comments/reactions/new.html.erb b/app/views/cards/comments/reactions/new.html.erb index 38c6daf98..e847acfbe 100644 --- a/app/views/cards/comments/reactions/new.html.erb +++ b/app/views/cards/comments/reactions/new.html.erb @@ -2,7 +2,7 @@ <%= form_with model: [ @comment.card, @comment, Reaction.new ], class: "reaction reaction__form expanded", html: { aria: { label: "New reaction" } }, - data: { controller: "form reaction-emoji", turbo_frame: dom_id(@comment, :reacting), action: "keydown.esc->form#cancel submit->form#preventEmptySubmit" } do |form| %> + data: { controller: "form reaction-emoji", turbo_frame: dom_id(@comment, :reacting), action: "keydown.esc->form#cancel submit->form#preventEmptySubmit turbo:submit-end->form#reset" } do |form| %>