Browse Source

Preserve path when reloading the app

Fixes #849.
Thibaut Courouble 7 years ago
parent
commit
a8a97e0198

+ 8 - 1
assets/javascripts/app/app.coffee

@@ -157,10 +157,17 @@
     new app.views.Updates()
     @updateChecker = new app.UpdateChecker()
 
+  reboot: ->
+    if location.pathname isnt '/'
+      window.location = "/##{location.pathname}"
+    else
+      window.location = '/'
+    return
+
   reload: ->
     @docs.clearCache()
     @disabledDocs.clearCache()
-    if @appCache then @appCache.reload() else window.location = '/'
+    if @appCache then @appCache.reload() else @reboot()
     return
 
   reset: ->

+ 5 - 1
assets/javascripts/app/appcache.coffee

@@ -27,7 +27,11 @@ class app.AppCache
     return
 
   reload: ->
-    $.on @cache, 'updateready noupdate error', -> window.location = '/'
+    $.on @cache, 'updateready noupdate error', ->
+      if location.pathname isnt '/'
+        window.location = "/##{location.pathname}"
+      else
+        window.location = '/'
     @notifyUpdate = false
     @notifyProgress = true
     try @cache.update() catch

+ 1 - 1
assets/javascripts/views/layout/document.coffee

@@ -77,7 +77,7 @@ class app.views.Document extends app.View
     switch target.getAttribute('data-behavior')
       when 'back'         then history.back()
       when 'reload'       then window.location.reload()
-      when 'reboot'       then window.location = '/'
+      when 'reboot'       then app.reboot()
       when 'hard-reload'  then app.reload()
       when 'reset'        then app.reset() if confirm('Are you sure you want to reset DevDocs?')
     return