mirror of
https://github.com/discourse/discourse.git
synced 2025-06-14 13:10:03 +08:00
FEATURE: Allow theme settings to request refresh (#15037)
Similar to site settings, adds support for `refresh` option to theme settings. ```yaml super_feature_enabled: type: bool default: false refresh: true ```
This commit is contained in:
@ -94,6 +94,13 @@ class Theme < ActiveRecord::Base
|
||||
clear_cached_settings!
|
||||
DB.after_commit { ColorScheme.hex_cache.clear }
|
||||
notify_theme_change(with_scheme: notify_with_scheme)
|
||||
|
||||
if theme_setting_requests_refresh
|
||||
DB.after_commit do
|
||||
Discourse.request_refresh!
|
||||
self.theme_setting_requests_refresh = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def update_child_components
|
||||
@ -572,6 +579,10 @@ class Theme < ActiveRecord::Base
|
||||
raise Discourse::NotFound unless target_setting
|
||||
|
||||
target_setting.value = new_value
|
||||
|
||||
if target_setting.requests_refresh?
|
||||
self.theme_setting_requests_refresh = true
|
||||
end
|
||||
end
|
||||
|
||||
def update_translation(translation_key, new_value)
|
||||
@ -727,6 +738,8 @@ class Theme < ActiveRecord::Base
|
||||
|
||||
private
|
||||
|
||||
attr_accessor :theme_setting_requests_refresh
|
||||
|
||||
def to_scss_variable(name, value)
|
||||
escaped = SassC::Script::Value::String.quote(value, sass: true)
|
||||
"$#{name}: unquote(#{escaped});"
|
||||
|
Reference in New Issue
Block a user