From c2c6e8f9f69d76ed8dd487fd48aa4a1aa56cf73d Mon Sep 17 00:00:00 2001 From: Patryk Tomczyk <13100280+patzick@users.noreply.github.com> Date: Fri, 2 Aug 2019 12:58:08 +0200 Subject: [PATCH 1/2] fix async chain in registering routes --- core/client-entry.ts | 2 +- core/modules/url/store/actions.ts | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/core/client-entry.ts b/core/client-entry.ts index 2321023600..b5cda344ba 100755 --- a/core/client-entry.ts +++ b/core/client-entry.ts @@ -23,7 +23,7 @@ const invokeClientEntry = async () => { store.replaceState(Object.assign({}, store.state, window.__INITIAL_STATE__, { config: globalConfig })) } - store.dispatch('url/registerDynamicRoutes') + await store.dispatch('url/registerDynamicRoutes') function _commonErrorHandler (err, reject) { if (err.message.indexOf('query returned empty result') > 0) { rootStore.dispatch('notification/spawnNotification', { diff --git a/core/modules/url/store/actions.ts b/core/modules/url/store/actions.ts index e5e87a6b35..e6e52482f4 100644 --- a/core/modules/url/store/actions.ts +++ b/core/modules/url/store/actions.ts @@ -30,12 +30,14 @@ export const actions: ActionTree = { * Register dynamic vue-router routes */ async registerDynamicRoutes ({ state, dispatch }) { - if (state.dispatcherMap) { - for (const [url, routeData] of Object.entries(state.dispatcherMap)) { - processDynamicRoute(routeData, url) - dispatch('registerMapping', { url, routeData }) - } - } + if (!state.dispatcherMap) return + + const registrationRoutePromises = Object.keys(state.dispatcherMap).map(url => { + const routeData = state.dispatcherMap[url] + processDynamicRoute(routeData, url) + return dispatch('registerMapping', { url, routeData }) + }) + await Promise.all(registrationRoutePromises) }, mapUrl ({ state, dispatch }, { url, query }: { url: string, query: string}) { const parsedQuery = typeof query === 'string' ? queryString.parse(query) : query From 4d45ab569f6af5ec7a910ae911c7e93ae4a1f5f9 Mon Sep 17 00:00:00 2001 From: Patryk Tomczyk <13100280+patzick@users.noreply.github.com> Date: Fri, 2 Aug 2019 13:02:53 +0200 Subject: [PATCH 2/2] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2fe033e4ef..fd75cd1421 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed static category links in cms contents on homepage and MinimalFooter - @MariaKern (#3292) - Fixed tax calulaction where products was send as parameter but products.items where the right paramater - @resubaka (#3308) - Fixed module extendStore for array property inside store - @przspa (#3311) +- Some SSR problems with urlDispatcher during multireloading page - @patzick (#3323) ### Changed / Improved