Fix anonymous blocks causing exceptions without inboxes

This commit is contained in:
Andreas Nedbal 2023-02-11 06:18:51 +01:00 committed by Andreas Nedbal
parent 4c0948c6d1
commit 5cb96a7907

View file

@ -16,12 +16,13 @@ class AnonymousBlockController < ApplicationController
target_user: question.user
)
inbox_id = question.inboxes.first.id
inbox_id = question.inboxes.first&.id
question.inboxes.first&.destroy
respond_to do |format|
format.turbo_stream do
render turbo_stream: turbo_stream.remove("inbox_#{inbox_id}")
inbox_id ? turbo_stream.remove("inbox_#{inbox_id}") : nil,
end
format.html { redirect_back(fallback_location: inbox_path) }