fix: Handle redirects for loading bar

This commit is contained in:
Sébastien Chopin 2018-01-12 16:10:30 +01:00
parent 28d3e6fdb3
commit e33d502696

View File

@ -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 = {}