Sfoglia il codice sorgente

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.
Thibaut Courouble 7 anni fa
parent
commit
e8d52c9cfd

+ 1 - 0
assets/javascripts/views/content/settings_page.coffee

@@ -28,6 +28,7 @@ class app.views.SettingsPage extends app.View
     html.classList.toggle('_theme-default')
     html.classList.toggle('_theme-dark')
     app.settings.set('dark', !!enable)
+    app.appCache?.updateInBackground()
     return
 
   toggleLayout: (layout, enable) ->

+ 13 - 0
test/app_test.rb

@@ -122,6 +122,19 @@ class AppTest < MiniTest::Spec
       refute_includes last_response.body, 'foo'
     end
 
+    it "has the word 'default' when no 'dark' cookie is set" do
+      get '/manifest.appcache'
+      assert_includes last_response.body, '# default'
+      refute_includes last_response.body, '# dark'
+    end
+
+    it "has the word 'dark' when the cookie is set" do
+      set_cookie('dark=1')
+      get '/manifest.appcache'
+      assert_includes last_response.body, '# dark'
+      refute_includes last_response.body, '# default'
+    end
+
     it "sets default size" do
       get '/manifest.appcache'
       assert_includes last_response.body, '20rem'

+ 1 - 1
views/manifest.erb

@@ -1,5 +1,5 @@
 CACHE MANIFEST
-# <%= app_size %> <%= app_layout %>
+# <%= app_theme %> <%= app_size %> <%= app_layout %>
 
 CACHE:
 /