From cc3c7ba532f75617505bb41297651a5c14f71bdd Mon Sep 17 00:00:00 2001 From: Claire Date: Fri, 16 Jan 2026 16:55:16 +0100 Subject: [PATCH] Fix `system` theme being included twice (#37526) --- app/helpers/theme_helper.rb | 12 ++++-------- spec/helpers/theme_helper_spec.rb | 14 +++----------- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/app/helpers/theme_helper.rb b/app/helpers/theme_helper.rb index e765541414..f651a495ff 100644 --- a/app/helpers/theme_helper.rb +++ b/app/helpers/theme_helper.rb @@ -18,14 +18,10 @@ module ThemeHelper end def theme_style_tags(theme) - if theme == 'system' - ''.html_safe.tap do |tags| - tags << vite_stylesheet_tag('themes/mastodon-light', type: :virtual, media: 'not all and (prefers-color-scheme: dark)', crossorigin: 'anonymous') - tags << vite_stylesheet_tag('themes/default', type: :virtual, media: '(prefers-color-scheme: dark)', crossorigin: 'anonymous') - end - else - vite_stylesheet_tag "themes/#{theme}", type: :virtual, media: 'all', crossorigin: 'anonymous' - end + # TODO: get rid of that when we retire the themes and perform the settings migration + theme = 'default' if %w(mastodon-light contrast system).include?(theme) + + vite_stylesheet_tag "themes/#{theme}", type: :virtual, media: 'all', crossorigin: 'anonymous' end def theme_color_tags(color_scheme) diff --git a/spec/helpers/theme_helper_spec.rb b/spec/helpers/theme_helper_spec.rb index 35798cced6..a402885711 100644 --- a/spec/helpers/theme_helper_spec.rb +++ b/spec/helpers/theme_helper_spec.rb @@ -9,17 +9,10 @@ RSpec.describe ThemeHelper do context 'when using "system" theme' do let(:theme) { 'system' } - it 'returns the mastodon-light and application stylesheets with correct color schemes' do + it 'returns the default theme' do expect(html_links.first.attributes.symbolize_keys) .to include( - # This is now identical to the default theme & will be unified very soon - href: have_attributes(value: match(/default/)), - media: have_attributes(value: 'not all and (prefers-color-scheme: dark)') - ) - expect(html_links.last.attributes.symbolize_keys) - .to include( - href: have_attributes(value: match(/default/)), - media: have_attributes(value: '(prefers-color-scheme: dark)') + href: have_attributes(value: match(/default/)) ) end end @@ -41,8 +34,7 @@ RSpec.describe ThemeHelper do it 'returns the theme stylesheet without color scheme information' do expect(html_links.first.attributes.symbolize_keys) .to include( - href: have_attributes(value: match(/default/)), - media: have_attributes(value: 'all') + href: have_attributes(value: match(/default/)) ) end end