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