Destroy Mute Rules using Turbo Streams

This commit is contained in:
Andreas Nedbal 2022-11-18 21:48:12 +01:00 committed by Andreas Nedbal
parent 589b753df3
commit c08ff04738
2 changed files with 15 additions and 3 deletions

View File

@ -18,4 +18,17 @@ class Settings::MutesController < ApplicationController
format.html { redirect_to settings_muted_path }
end
end
def destroy
rule = MuteRule.find(params[:id])
rule.destroy!
respond_to do |format|
format.turbo_stream do
render turbo_stream: turbo_stream.remove("rule_#{params[:id]}")
end
format.html { redirect_to settings_muted_path }
end
end
end

View File

@ -82,6 +82,8 @@ Rails.application.routes.draw do
post :export, to: "export#create"
get :muted, to: "mutes#index"
post :muted, to: "mutes#create"
delete "muted/:id", to: "mutes#destroy", as: :muted_destroy
get :blocks, to: "blocks#index"
@ -130,9 +132,6 @@ Rails.application.routes.draw do
post "/list_membership", to: "list#membership", as: :list_membership
post "/subscribe", to: "subscription#subscribe", as: :subscribe_answer
post "/unsubscribe", to: "subscription#unsubscribe", as: :unsubscribe_answer
post "/mute", to: "mute_rule#create", as: :create_mute_rule
post "/mute/:id", to: "mute_rule#update", as: :update_mute_rule
delete "/mute/:id", to: "mute_rule#destroy", as: :delete_mute_rule
post "/block_anon", to: "anonymous_block#create", as: :block_anon
delete "/block_anon/:id", to: "anonymous_block#destroy", as: :unblock_anon
end