Skip to content

A platform for community discussion. Free, open, simple.

DEV: Improve system theme loading (#34954)

David Taylor85cd05a520a5
diff --git a/config/initializers/999-themes.rb b/config/initializers/999-themes.rb
index e875b71b9a9..a1469e3035a 100644
--- a/config/initializers/999-themes.rb
+++ b/config/initializers/999-themes.rb
@@ -18,14 +18,16 @@ Rails.application.config.after_initialize do |config|
(theme_field = find_js_field(theme, filepath)) ||
(theme_field = find_scss_field(theme, filepath))
)
- theme_field.update!(value: File.read(modified[0]))
- theme.update_javascript_cache!
- Stylesheet::Manager.clear_theme_cache!
- Theme.expire_site_cache!
+ theme = theme_field.theme
+ theme.set_field(
+ target: theme_field.target_name,
+ name: theme_field.name,
+ value: File.read(modified[0]),
+ )
+ theme.save!
else
SystemThemesManager.sync_theme!(theme_name)
end
- MessageBus.publish "/file-change", ["development-mode-theme-changed"]
end
listener.start
end
diff --git a/lib/system_themes_manager.rb b/lib/system_themes_manager.rb
index 200e36d8351..6f4d87a44a3 100644
--- a/lib/system_themes_manager.rb
+++ b/lib/system_themes_manager.rb
@@ -13,17 +13,17 @@ class SystemThemesManager
is_initial_install = !Theme.exists?(id: theme_id)
- remote_theme = RemoteTheme.import_theme_from_directory(theme_dir, theme_id: theme_id)
- remote_theme.update_column(:enabled, true)
+ theme = RemoteTheme.import_theme_from_directory(theme_dir, theme_id: theme_id)
+ theme.update_column(:enabled, true)
if is_initial_install
if theme_id == Theme::CORE_THEMES["horizon"]
- remote_theme.update!(
- dark_color_scheme: remote_theme.color_schemes.find_by(name: "Horizon Dark"),
- )
+ theme.update!(dark_color_scheme: theme.color_schemes.find_by(name: "Horizon Dark"))
end
end
+ theme.save!
+
Stylesheet::Manager.clear_theme_cache!
end