2022-11-02 09:41:30 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Chat::CategoryExtension
|
|
|
|
extend ActiveSupport::Concern
|
|
|
|
|
|
|
|
include Chatable
|
|
|
|
|
2022-11-17 09:16:14 -05:00
|
|
|
prepended { has_one :category_channel, as: :chatable, dependent: :destroy }
|
2022-11-02 09:41:30 -04:00
|
|
|
|
|
|
|
def cannot_delete_reason
|
|
|
|
return I18n.t("category.cannot_delete.has_chat_channels") if category_channel
|
|
|
|
super
|
|
|
|
end
|
2022-11-03 12:21:17 -04:00
|
|
|
|
|
|
|
def deletable_for_chat?
|
|
|
|
return true if !category_channel
|
|
|
|
category_channel.chat_messages_empty?
|
|
|
|
end
|
2022-11-02 09:41:30 -04:00
|
|
|
end
|