History

Update AppCache in background when toggling light and enabling docs inline

Thibaut committed 11 years ago

Commit 8de2dd61 parent 9a99e793 files · +10 −3Browse files

Unified · Split

3 files
  1. assets/javascripts/app/app.coffee +1 −0
  2. assets/javascripts/app/appcache.coffee +8 −3
  3. assets/javascripts/views/layout/document.coffee +1 −0
assets/javascripts/app/app.coffee+1−0
@@ -102,6 +102,7 @@ · 101 unmodified lines
102 @initDoc(doc)102 @initDoc(doc)
103 @settings.setDocs(doc.slug for doc in @docs.all())103 @settings.setDocs(doc.slug for doc in @docs.all())
104 _onSuccess()104 _onSuccess()
105 @appCache?.updateInBackground()
105 return106 return
106 107
107 doc.load onSuccess, onError, writeCache: true108 doc.load onSuccess, onError, writeCache: true
assets/javascripts/app/appcache.coffee+8−3
@@ -14,13 +14,18 @@ class app.AppCache · 13 unmodified lines
14 $.on @cache, 'updateready', @onUpdateReady14 $.on @cache, 'updateready', @onUpdateReady
15 15
16 update: ->16 update: ->
17 @notifyUpdate = true
18 try @cache.update() catch
19 return
20
21 updateInBackground: ->
22 @notifyUpdate = false
17 try @cache.update() catch23 try @cache.update() catch
18 return24 return
19 25
20 reload: ->26 reload: ->
21 @reloading = true
22 $.on @cache, 'updateready noupdate error', -> window.location = '/'27 $.on @cache, 'updateready noupdate error', -> window.location = '/'
23 @update()28 @updateInBackground()
24 return29 return
25 30
26 onProgress: (event) =>31 onProgress: (event) =>
@@ -28,5 +33,5 @@ class app.AppCache · 1 unmodified line
28 return33 return
29 34
30 onUpdateReady: =>35 onUpdateReady: =>
31 @trigger 'updateready' unless @reloading36 @trigger 'updateready' if @notifyUpdate
32 return37 return
assets/javascripts/views/layout/document.coffee+1−0
@@ -23,6 +23,7 @@ class app.views.Document extends app.View · 22 unmodified lines
23 css.setAttribute('data-alt', css.getAttribute('href'))23 css.setAttribute('data-alt', css.getAttribute('href'))
24 css.setAttribute('href', alt)24 css.setAttribute('href', alt)
25 app.settings.setDark(alt.indexOf('dark') > 0)25 app.settings.setDark(alt.indexOf('dark') > 0)
26 app.appCache?.updateInBackground()
26 return27 return
27 28
28 setTitle: (title) ->29 setTitle: (title) ->