@@ -33,7 +33,9 @@ function getEnvironmentState() {
33
33
} ;
34
34
35
35
function getDebugState ( ) {
36
- return { savedPath : DebugStore . get ( ) . currentRoutePath } ;
36
+ return {
37
+ debug : DebugStore . get ( )
38
+ } ;
37
39
}
38
40
39
41
var Root = React . createClass ( {
@@ -48,7 +50,10 @@ var Root = React.createClass({
48
50
} ,
49
51
50
52
onUserChange : function ( ) {
51
- this . setState ( getUserState ( ) ) ;
53
+ var state = getUserState ( ) ;
54
+ // reset the route stack on user change.
55
+ state . routeStack = null ;
56
+ this . setState ( state ) ;
52
57
} ,
53
58
54
59
onEnvChange : function ( ) {
@@ -76,17 +81,27 @@ var Root = React.createClass({
76
81
CurrentUserStore . removeChangeListener ( this . onUserChange ) ;
77
82
} ,
78
83
79
- getSavedPath : function ( ) {
80
- if ( ! this . state . environment ) { return null ; }
81
- if ( ! this . state . environment . data . simulator ) { return null ; }
84
+ getSavedCurrentRoutePath : function ( ) {
85
+ if ( ! this . state . environment . data . simulator ) { return null ; }
86
+ if ( this . state . environment . data . name === 'test' ) { return null ; }
87
+
88
+ return this . state . debug . currentRoutePath ;
89
+ } ,
82
90
83
- return this . state . savedPath ;
91
+ getDefaultRouteStack : function ( ) {
92
+ return Routes . parse ( null , this . state . user . isLoggedIn ( ) , true ) ;
84
93
} ,
85
94
86
95
renderContent : function ( ) {
87
96
if ( this . state . routeUnderTest ) return null ;
88
97
89
- var routeStack = Routes . parse ( this . getSavedPath ( ) , this . state . user . isLoggedIn ( ) , true ) ;
98
+ var routeStack = this . state . routeStack ;
99
+ if ( ! routeStack && this . getSavedCurrentRoutePath ( ) ) {
100
+ routeStack = Routes . parse ( this . getSavedCurrentRoutePath ( ) , this . state . user . isLoggedIn ( ) , true ) ;
101
+ }
102
+ if ( ! routeStack ) {
103
+ routeStack = this . getDefaultRouteStack ( ) ;
104
+ }
90
105
91
106
if ( this . state . user . isLoggedIn ( ) ) {
92
107
return (
@@ -103,7 +118,7 @@ var Root = React.createClass({
103
118
104
119
render : function ( ) {
105
120
// need to fetch current user and environment before launching
106
- if ( ! this . state . user || ! this . state . environment ) {
121
+ if ( ! this . state . user || ! this . state . environment || ! this . state . debug ) {
107
122
return ( < Launch ref = "current" /> ) ;
108
123
}
109
124
else if ( this . state . environment . data . name === 'test' ) {
0 commit comments