mirror of
https://github.com/discourse/discourse.git
synced 2025-04-27 03:44:31 +08:00
FIX: Chat NotificationLevels extension breaking in prod (#21484)
When setting DISCOURSE_ZEITWERK_EAGER_LOAD=1 to enable eager loading the previous solution to adding chat_levels to the core NotificationLevels would break with a module loading error (c.f. cc2570fce38579202d0e295c153310310f6feb14) We don't actually _need_ to extend the core class, we can just make our own for chat, let's do this instead.
This commit is contained in:
parent
79812db7d3
commit
616885895a
plugins/chat
@ -8,7 +8,7 @@ module Chat
|
||||
belongs_to :last_read_message, class_name: "Chat::Message", optional: true
|
||||
belongs_to :thread, class_name: "Chat::Thread", foreign_key: :thread_id
|
||||
|
||||
enum :notification_level, NotificationLevels.chat_levels
|
||||
enum :notification_level, Chat::NotificationLevels.all
|
||||
end
|
||||
end
|
||||
|
||||
|
9
plugins/chat/lib/chat/notification_levels.rb
Normal file
9
plugins/chat/lib/chat/notification_levels.rb
Normal file
@ -0,0 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Chat
|
||||
class NotificationLevels
|
||||
def self.all
|
||||
@all_levels ||= Enum.new(muted: 0, normal: 1, tracking: 2, watching: 3)
|
||||
end
|
||||
end
|
||||
end
|
@ -1,13 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module Chat
|
||||
module NotificationLevelsExtension
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
class_methods do
|
||||
def chat_levels
|
||||
@chat_levels ||= Enum.new(muted: 0, normal: 1, tracking: 2, watching: 3)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -63,7 +63,6 @@ after_initialize do
|
||||
User.prepend Chat::UserExtension
|
||||
Jobs::UserEmail.prepend Chat::UserEmailExtension
|
||||
Plugin::Instance.prepend Chat::PluginInstanceExtension
|
||||
NotificationLevels.prepend Chat::NotificationLevelsExtension
|
||||
end
|
||||
|
||||
if Oneboxer.respond_to?(:register_local_handler)
|
||||
|
Loading…
x
Reference in New Issue
Block a user