@@ -2,17 +2,18 @@ import { LoadBundle, ChangeLocation } from './effects'
22
33import { getPathInfo } from './utils'
44
5- // Sets a value to the given key in the state
65export const ParseUrl = ( state , path ) => {
7- const pathInfo = getPathInfo ( state , path )
8-
96 // Set location params
7+ const pathInfo = getPathInfo ( state , path )
108 const next = {
119 ...state ,
1210 location : pathInfo
1311 }
1412
15- return ( pathInfo . route && ! pathInfo . loaded ) ? TriggerPageLoad ( next , pathInfo . path ) : next
13+ // If route exists and isn't loaded, load it
14+ return ( pathInfo . route && ! pathInfo . loaded )
15+ ? TriggerPageLoad ( next , pathInfo . path )
16+ : next
1617}
1718
1819const BundleLoaded = ( state , { path, bundle } ) => {
@@ -33,8 +34,7 @@ const BundleLoaded = (state, { path, bundle }) => {
3334 }
3435
3536 if ( bundle . Init ) {
36- const pathInfo = getPathInfo ( withBundleLoaded , path )
37- const withPageInitiated = {
37+ const markedAsInitiated = {
3838 ...withBundleLoaded ,
3939 pageData : {
4040 ...withBundleLoaded . pageData ,
@@ -44,7 +44,11 @@ const BundleLoaded = (state, { path, bundle }) => {
4444 }
4545 }
4646 }
47- return bundle . Init ( withPageInitiated , pathInfo )
47+
48+ return bundle . Init (
49+ markedAsInitiated ,
50+ getPathInfo ( withBundleLoaded , path )
51+ )
4852 }
4953
5054 return withBundleLoaded
@@ -70,8 +74,6 @@ export const TriggerPageLoad = (state, path) => {
7074
7175 const pageData = state . pageData [ path ]
7276
73- // console.log('TriggerPageLoad', state)
74-
7577 if ( matchedRoute && ! matchedRoute . view && ! matchedRoute . loading ) {
7678 return [
7779 {
0 commit comments