Add TurboStreamable concern to Settings::MutesController

This commit is contained in:
Andreas Nedbal 2023-02-11 06:19:57 +01:00 committed by Andreas Nedbal
parent f2024a990e
commit c880fade4e
2 changed files with 15 additions and 2 deletions

View File

@ -3,6 +3,10 @@
class Settings::MutesController < ApplicationController class Settings::MutesController < ApplicationController
before_action :authenticate_user! before_action :authenticate_user!
def turbo_stream_actions = %i[create destroy]
include TurboStreamable
def index def index
@users = current_user.muted_users @users = current_user.muted_users
@rules = MuteRule.where(user: current_user) @rules = MuteRule.where(user: current_user)
@ -15,7 +19,8 @@ class Settings::MutesController < ApplicationController
format.turbo_stream do format.turbo_stream do
render turbo_stream: [ render turbo_stream: [
turbo_stream.replace("form", partial: "settings/mutes/form"), turbo_stream.replace("form", partial: "settings/mutes/form"),
turbo_stream.append("rules", partial: "settings/mutes/rule", locals: { rule: result[:resource] }) turbo_stream.append("rules", partial: "settings/mutes/rule", locals: { rule: result[:resource] }),
render_toast(t(".success"))
] ]
end end
@ -32,7 +37,10 @@ class Settings::MutesController < ApplicationController
respond_to do |format| respond_to do |format|
format.turbo_stream do format.turbo_stream do
render turbo_stream: turbo_stream.remove("rule_#{params[:id]}") render turbo_stream: [
turbo_stream.remove("rule_#{params[:id]}"),
render_toast(t(".success"))
]
end end
format.html { redirect_to settings_muted_path } format.html { redirect_to settings_muted_path }

View File

@ -160,6 +160,11 @@ en:
create: create:
success: "Your account is currently being exported. This will take a little while." success: "Your account is currently being exported. This will take a little while."
error: "Exporting is currently not possible." error: "Exporting is currently not possible."
mutes:
create:
success: "Sucessfully created mute rule"
destroy:
success: "Successfully removed mute rule"
privacy: privacy:
update: update:
success: :settings.profile.update.success success: :settings.profile.update.success