@@ -83,8 +83,7 @@ class App extends Component<Props, State> {
8383 } ) ) ;
8484 } ) ,
8585 syncAccountsList ( accounts => {
86- const oldAccountsLen = this . state . accounts . length ;
87- this . setState ( { accounts } , ( ) => this . maybeRoute ( oldAccountsLen ) ) ;
86+ this . setState ( { accounts } , ( ) => this . maybeRoute ( ) ) ;
8887 } ) ,
8988 syncDeviceList ( ( devices ) => {
9089 this . setStateWithDeviceList ( { devices } ) ;
@@ -94,7 +93,6 @@ class App extends Component<Props, State> {
9493
9594 private setStateWithDeviceList ( newState : Partial < State > ) {
9695 const oldDeviceIDList = Object . keys ( this . state . devices ) ;
97- const oldAccountsLen = this . state . accounts . length ;
9896 this . setState ( currentState => ( { ...currentState , ...newState } ) , ( ) => {
9997 const newDeviceIDList : string [ ] = Object . keys ( this . state . devices ) ;
10098 // If a device is newly connected, we route to the settings.
@@ -114,15 +112,15 @@ class App extends Component<Props, State> {
114112 return ;
115113 }
116114 }
117- this . maybeRoute ( oldAccountsLen ) ;
115+ this . maybeRoute ( ) ;
118116 } ) ;
119117 }
120118
121119 public componentWillUnmount ( ) {
122120 unsubscribe ( this . unsubscribeList ) ;
123121 }
124122
125- private maybeRoute = ( oldAccountsLen : number ) => {
123+ private maybeRoute = ( ) => {
126124 const currentURL = window . location . pathname ;
127125 const isIndex = currentURL === '/' || currentURL === '/index.html' || currentURL === '/android_asset/web/index.html' ;
128126 const inAccounts = currentURL . startsWith ( '/account/' ) ;
@@ -149,13 +147,13 @@ class App extends Component<Props, State> {
149147 route ( '/' , true ) ;
150148 return ;
151149 }
152- // if on an account that isnt registered route to /
150+ // if on an account that isn't registered route to /
153151 if ( inAccounts && ! accounts . some ( account => currentURL . startsWith ( '/account/' + account . code ) ) ) {
154152 route ( '/' , true ) ;
155153 return ;
156154 }
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 ) {
159157 route ( '/account-summary' , true ) ;
160158 return ;
161159 }
0 commit comments