Skip to content

Commit e8d52c9

Browse files
committed
Fix app cache not updating when changing the app's color theme
This is needed because the index page is part of the app cache, and the <html> tag has a different class depending on the theme.
1 parent d72de33 commit e8d52c9

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

assets/javascripts/views/content/settings_page.coffee

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class app.views.SettingsPage extends app.View
2828
html.classList.toggle('_theme-default')
2929
html.classList.toggle('_theme-dark')
3030
app.settings.set('dark', !!enable)
31+
app.appCache?.updateInBackground()
3132
return
3233

3334
toggleLayout: (layout, enable) ->

test/app_test.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,19 @@ def app
122122
refute_includes last_response.body, 'foo'
123123
end
124124

125+
it "has the word 'default' when no 'dark' cookie is set" do
126+
get '/manifest.appcache'
127+
assert_includes last_response.body, '# default'
128+
refute_includes last_response.body, '# dark'
129+
end
130+
131+
it "has the word 'dark' when the cookie is set" do
132+
set_cookie('dark=1')
133+
get '/manifest.appcache'
134+
assert_includes last_response.body, '# dark'
135+
refute_includes last_response.body, '# default'
136+
end
137+
125138
it "sets default size" do
126139
get '/manifest.appcache'
127140
assert_includes last_response.body, '20rem'

views/manifest.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CACHE MANIFEST
2-
# <%= app_size %> <%= app_layout %>
2+
# <%= app_theme %> <%= app_size %> <%= app_layout %>
33

44
CACHE:
55
/

0 commit comments

Comments
 (0)