0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-06 09:44:06 +08:00
discourse/config/initializers/015-track-upcoming-change-toggle.rb
David Battersby 744d07c588
DEV: remove simple email subject upcoming change metadata (#41807)
We want to allow users to choose between email subject formats, so we
will retire this setting at `stable` and remove the associated upcoming
change metadata. The site setting action was also updated to follow the
convention adopted in other site setting actions by inheriting from
`Service::ActionBase` and passing an `enabled` value as true/false.

I have moved the call site for this site setting toggle from track
upcoming change toggle over to the track site setting initializer.
2026-07-20 14:43:00 +04:00

35 lines
1.6 KiB
Ruby
Vendored

# frozen_string_literal: true
Rails.application.config.after_initialize { UpcomingChanges.clear_caches! }
#
# Similar to 014-track-setting-changes.rb, we can react to upcoming changes
# being enabled/or disabled here for more complicated scenarios, where
# we are not just changing UI or behaviour when the state of the underlying
# setting is changed.
#
# We need to do this separately from 014-track-setting-changes.rb because
# we don't actually change the underlying setting value in the database
# when an upcoming change is automatically promoted. See UpcomingChanges::NotifyPromotions
# for further context.
#
# We do also send these events when admins manually opt-in or opt-out of an upcoming change
# via the UI and the UpcomingChanges::Toggle service.
DiscourseEvent.on(:upcoming_change_enabled) do |setting_name|
# Respond to event here, e.g. if setting_name == :enable_form_templates do X.
if setting_name == :enable_horizon_high_context_topic_cards
Themes::Action::HorizonHighContextTopicCardsToggled.call(enabled: true)
elsif setting_name == :remove_and_replace_uncategorized
SiteSetting::Action::RemoveAndReplaceUncategorizedToggled.call(enabled: true)
end
end
DiscourseEvent.on(:upcoming_change_disabled) do |setting_name|
# Respond to event here, e.g. if setting_name == :enable_form_templates do X.
if setting_name == :enable_horizon_high_context_topic_cards
Themes::Action::HorizonHighContextTopicCardsToggled.call(enabled: false)
elsif setting_name == :remove_and_replace_uncategorized
SiteSetting::Action::RemoveAndReplaceUncategorizedToggled.call(enabled: false)
end
end