@@ -83,8 +83,7 @@ class App extends Component<Props, State> {
83
83
} ) ) ;
84
84
} ) ,
85
85
syncAccountsList ( accounts => {
86
- const oldAccountsLen = this . state . accounts . length ;
87
- this . setState ( { accounts } , ( ) => this . maybeRoute ( oldAccountsLen ) ) ;
86
+ this . setState ( { accounts } , ( ) => this . maybeRoute ( ) ) ;
88
87
} ) ,
89
88
syncDeviceList ( ( devices ) => {
90
89
this . setStateWithDeviceList ( { devices } ) ;
@@ -94,7 +93,6 @@ class App extends Component<Props, State> {
94
93
95
94
private setStateWithDeviceList ( newState : Partial < State > ) {
96
95
const oldDeviceIDList = Object . keys ( this . state . devices ) ;
97
- const oldAccountsLen = this . state . accounts . length ;
98
96
this . setState ( currentState => ( { ...currentState , ...newState } ) , ( ) => {
99
97
const newDeviceIDList : string [ ] = Object . keys ( this . state . devices ) ;
100
98
// If a device is newly connected, we route to the settings.
@@ -114,15 +112,15 @@ class App extends Component<Props, State> {
114
112
return ;
115
113
}
116
114
}
117
- this . maybeRoute ( oldAccountsLen ) ;
115
+ this . maybeRoute ( ) ;
118
116
} ) ;
119
117
}
120
118
121
119
public componentWillUnmount ( ) {
122
120
unsubscribe ( this . unsubscribeList ) ;
123
121
}
124
122
125
- private maybeRoute = ( oldAccountsLen : number ) => {
123
+ private maybeRoute = ( ) => {
126
124
const currentURL = window . location . pathname ;
127
125
const isIndex = currentURL === '/' || currentURL === '/index.html' || currentURL === '/android_asset/web/index.html' ;
128
126
const inAccounts = currentURL . startsWith ( '/account/' ) ;
@@ -149,13 +147,13 @@ class App extends Component<Props, State> {
149
147
route ( '/' , true ) ;
150
148
return ;
151
149
}
152
- // if on an account that isnt registered route to /
150
+ // if on an account that isn't registered route to /
153
151
if ( inAccounts && ! accounts . some ( account => currentURL . startsWith ( '/account/' + account . code ) ) ) {
154
152
route ( '/' , true ) ;
155
153
return ;
156
154
}
157
- // if on index page and we go from zero accounts to at least 1 account, route to /account-summary
158
- if ( isIndex && oldAccountsLen === 0 && accounts . length ) {
155
+ // if on index page and have at least 1 account, route to /account-summary
156
+ if ( isIndex && accounts . length ) {
159
157
route ( '/account-summary' , true ) ;
160
158
return ;
161
159
}
0 commit comments