From e33d5026966e23d71dc33078a9122bf4a9fccd61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Chopin?= Date: Fri, 12 Jan 2018 16:10:30 +0100 Subject: [PATCH] fix: Handle redirects for loading bar --- lib/app/client.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/app/client.js b/lib/app/client.js index 6ac5cba5ae..456eac1776 100644 --- a/lib/app/client.js +++ b/lib/app/client.js @@ -197,9 +197,11 @@ async function render (to, from, next) { // nextCalled is true when redirected let nextCalled = false const _next = path => { - <% if(loading) { %>if(this.$loading.finish) this.$loading.finish()<% } %> + <% if(loading) { %>if (from.path === path.path && this.$loading.finish) this.$loading.finish()<% } %> + <% if(loading) { %>if (from.path !== path.path && this.$loading.pause) this.$loading.pause()<% } %> if (nextCalled) return nextCalled = true + _lastPaths = getMatchedComponents(from).map((Component, i) => compile(from.matched[i].path)(from.params)) next(path) } @@ -327,12 +329,12 @@ async function render (to, from, next) { return Promise.all(promises) })) - _lastPaths = Components.map((Component, i) => compile(to.matched[i].path)(to.params)) - - <% if(loading) { %>if(this.$loading.finish) this.$loading.finish()<% } %> - // If not redirected - if (!nextCalled) next() + if (!nextCalled) { + <% if (loading) { %>if(this.$loading.finish) this.$loading.finish()<% } %> + _lastPaths = Components.map((Component, i) => compile(to.matched[i].path)(to.params)) + next() + } } catch (error) { if (!error) error = {}