Skip to content

Commit

Permalink
Fix routing issues in NwjsInstanceInitializer
Browse files Browse the repository at this point in the history
when refreshing the app in debug mode while not being on the IndexRoute

dc132d8
  • Loading branch information
bastimeyer committed Aug 5, 2019
1 parent dc132d8 commit e4578f4
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/app/init/instance-initializers/nwjs/instance-initializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ export default {
const settings = application.lookup( "service:settings" );

// add event listener before routing starts
const indexRoutePromise = new Promise( resolve => {
const routingPromise = new Promise( resolve => {
const listener = transition => {
if ( transition.to && transition.to.name === "index" ) {
if ( transition.to ) {
router.off( "routeDidChange", listener );
resolve( transition );
resolve( transition.to.name );
}
};
router.on( "routeDidChange", listener );
Expand All @@ -59,10 +59,12 @@ export default {
await new Promise( resolve => requestAnimationFrame( resolve ) );
}

// wait until the IndexRoute is loaded
await indexRoutePromise;
// wait until the target route is loaded
const routeName = await routingPromise;
// then load the user's homepage, but don't await the completion of the transition
router.homepage( true );
if ( routeName === "index" ) {
router.homepage( true );
}

// add "initialized" class name to the document element just before showing the window
const document = application.lookup( "service:-document" );
Expand Down

0 comments on commit e4578f4

Please sign in to comment.