Add TurboStreamable concern to AnonymousBlock controller

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

View File

@ -3,6 +3,10 @@
class AnonymousBlockController < ApplicationController
before_action :authenticate_user!
def turbo_stream_actions = %i[create destroy]
include TurboStreamable
def create
params.require :question
@ -21,8 +25,10 @@ class AnonymousBlockController < ApplicationController
respond_to do |format|
format.turbo_stream do
render turbo_stream: turbo_stream.remove("inbox_#{inbox_id}")
render turbo_stream: [
inbox_id ? turbo_stream.remove("inbox_#{inbox_id}") : nil,
render_toast(t(".success"))
].compact
end
format.html { redirect_back(fallback_location: inbox_path) }
@ -39,7 +45,10 @@ class AnonymousBlockController < ApplicationController
respond_to do |format|
format.turbo_stream do
render turbo_stream: turbo_stream.remove("block_#{params[:id]}")
render turbo_stream: [
turbo_stream.remove("block_#{params[:id]}"),
render_toast(t(".success"))
]
end
format.html { redirect_back(fallback_location: settings_blocks_path) }

View File

@ -144,6 +144,11 @@ en:
zero: "You are not currently subscribed to push notifications on any devices."
one: "You are currently receiving push notifications on one device."
other: "You are currently receiving push notifications on %{count} devices."
anonymous_block:
create:
success: "Successfully blocked user."
destroy:
success: "Successfully unblocked user."
inbox:
author:
info: "No questions from @%{author} found, showing entries from all users instead!"