@@ -58,6 +58,9 @@ export const App = () => {
5858
5959 const prevDevices = usePrevious ( devices ) ;
6060
61+ const deviceIDs = Object . keys ( devices ) ;
62+ const firstDevice = deviceIDs [ 0 ] ;
63+
6164 useEffect ( ( ) => {
6265 return syncNewTxs ( ( meta ) => {
6366 notifyUser ( t ( 'notification.newTxs' , {
@@ -71,7 +74,6 @@ export const App = () => {
7174 const currentURL = window . location . hash . replace ( / ^ # / , '' ) ;
7275 const isIndex = currentURL === '' || currentURL === '/' ;
7376 const inAccounts = currentURL . startsWith ( '/account/' ) ;
74- const deviceIDs = Object . keys ( devices ) ;
7577
7678 // QT and Android start their apps in '/index.html' and '/android_asset/web/index.html' respectively
7779 // This re-routes them to '/' so we have a simpler uri structure
@@ -106,9 +108,10 @@ export const App = () => {
106108 // if device is connected route to device settings
107109 if (
108110 deviceIDs . length === 1
111+ && firstDevice
109112 && currentURL === '/settings/no-device-connected'
110113 ) {
111- navigate ( `/settings/device-settings/${ deviceIDs [ 0 ] as string } ` ) ;
114+ navigate ( `/settings/device-settings/${ firstDevice } ` ) ;
112115 return ;
113116 }
114117 // if on an account that isn't registered route to /
@@ -138,7 +141,7 @@ export const App = () => {
138141 return ;
139142 }
140143
141- } , [ accounts , devices , navigate ] ) ;
144+ } , [ accounts , deviceIDs , firstDevice , navigate ] ) ;
142145
143146 useEffect ( ( ) => {
144147 const oldDeviceIDList = Object . keys ( prevDevices || { } ) ;
@@ -159,7 +162,7 @@ export const App = () => {
159162 if ( firstNewDevice ) {
160163 const productName = devices [ firstNewDevice ] ;
161164 if ( productName === 'bitbox' || productName === 'bitbox02-bootloader' ) {
162- navigate ( `settings/device-settings/${ newDeviceIDList [ 0 ] as string } ` ) ;
165+ navigate ( `settings/device-settings/${ firstNewDevice } ` ) ;
163166 return ;
164167 }
165168 }
@@ -173,10 +176,8 @@ export const App = () => {
173176 return prefix + ':' + JSON . stringify ( devices , Object . keys ( devices ) . sort ( ) ) ;
174177 } ;
175178
176- const deviceIDs : string [ ] = Object . keys ( devices ) ;
177179 const activeAccounts = accounts . filter ( acct => acct . active ) ;
178180
179- const firstDevice = deviceIDs [ 0 ] ;
180181 const isBitboxBootloader = firstDevice && devices [ firstDevice ] === 'bitbox02-bootloader' ;
181182 const showBottomNavigation = ( deviceIDs . length > 0 || activeAccounts . length > 0 ) && ! isBitboxBootloader ;
182183
0 commit comments