Unified · Split
| @@ -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 | return | 106 | return |
| 106 | 107 | ||
| 107 | doc.load onSuccess, onError, writeCache: true | 108 | doc.load onSuccess, onError, writeCache: true |
| @@ -14,13 +14,18 @@ class app.AppCache · 13 unmodified lines | |||
| 14 | $.on @cache, 'updateready', @onUpdateReady | 14 | $.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() catch | 23 | try @cache.update() catch |
| 18 | return | 24 | 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 | return | 29 | return |
| 25 | 30 | ||
| 26 | onProgress: (event) => | 31 | onProgress: (event) => |
| @@ -28,5 +33,5 @@ class app.AppCache · 1 unmodified line | |||
| 28 | return | 33 | return |
| 29 | 34 | ||
| 30 | onUpdateReady: => | 35 | onUpdateReady: => |
| 31 | @trigger 'updateready' unless @reloading | 36 | @trigger 'updateready' if @notifyUpdate |
| 32 | return | 37 | return |
| @@ -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 | return | 27 | return |
| 27 | 28 | ||
| 28 | setTitle: (title) -> | 29 | setTitle: (title) -> |