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
102102 @initDoc(doc)
103103 @settings.setDocs(doc.slug for doc in @docs.all())
104104 _onSuccess()
105+ @appCache?.updateInBackground()
105106 return
106107
107108 doc.load onSuccess, onError, writeCache: true
assets/javascripts/app/appcache.coffee+8−3
@@ -14,13 +14,18 @@ class app.AppCache · 13 unmodified lines
1414 $.on @cache, 'updateready', @onUpdateReady
1515
1616 update: ->
17+ @notifyUpdate = true
18+ try @cache.update() catch
19+ return
20+
21+ updateInBackground: ->
22+ @notifyUpdate = false
1723 try @cache.update() catch
1824 return
1925
2026 reload: ->
21− @reloading = true
2227 $.on @cache, 'updateready noupdate error', -> window.location = '/'
23− @update()
28+ @updateInBackground()
2429 return
2530
2631 onProgress: (event) =>
@@ -28,5 +33,5 @@ class app.AppCache · 1 unmodified line
2833 return
2934
3035 onUpdateReady: =>
31− @trigger 'updateready' unless @reloading
36+ @trigger 'updateready' if @notifyUpdate
3237 return
assets/javascripts/views/layout/document.coffee+1−0
@@ -23,6 +23,7 @@ class app.views.Document extends app.View · 22 unmodified lines
2323 css.setAttribute('data-alt', css.getAttribute('href'))
2424 css.setAttribute('href', alt)
2525 app.settings.setDark(alt.indexOf('dark') > 0)
26+ app.appCache?.updateInBackground()
2627 return
2728
2829 setTitle: (title) ->