@@ -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 ] } ` ) ;
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 || { } ) ;
@@ -155,10 +158,13 @@ export const App = () => {
155158 // We don't bother implementing the same for the bitbox01.
156159 // The bb02 bootloader screen is not full screen, so we don't mount it globally and instead
157160 // route to it.
158- const productName = devices [ newDeviceIDList [ 0 ] ] ;
159- if ( productName === 'bitbox' || productName === 'bitbox02-bootloader' ) {
160- navigate ( `settings/device-settings/${ newDeviceIDList [ 0 ] } ` ) ;
161- return ;
161+ const firstNewDevice = newDeviceIDList [ 0 ] ;
162+ if ( firstNewDevice ) {
163+ const productName = devices [ firstNewDevice ] ;
164+ if ( productName === 'bitbox' || productName === 'bitbox02-bootloader' ) {
165+ navigate ( `settings/device-settings/${ firstNewDevice } ` ) ;
166+ return ;
167+ }
162168 }
163169 }
164170 maybeRoute ( ) ;
@@ -170,10 +176,9 @@ export const App = () => {
170176 return prefix + ':' + JSON . stringify ( devices , Object . keys ( devices ) . sort ( ) ) ;
171177 } ;
172178
173- const deviceIDs : string [ ] = Object . keys ( devices ) ;
174179 const activeAccounts = accounts . filter ( acct => acct . active ) ;
175180
176- const isBitboxBootloader = devices [ deviceIDs [ 0 ] ] === 'bitbox02-bootloader' ;
181+ const isBitboxBootloader = firstDevice && devices [ firstDevice ] === 'bitbox02-bootloader' ;
177182 const showBottomNavigation = ( deviceIDs . length > 0 || activeAccounts . length > 0 ) && ! isBitboxBootloader ;
178183
179184
@@ -187,7 +192,10 @@ export const App = () => {
187192 accounts = { activeAccounts }
188193 devices = { devices }
189194 />
190- < div className = { `${ styles . appContent } ${ showBottomNavigation ? styles . hasBottomNavigation : '' } ` } >
195+ < div className = { `
196+ ${ styles . appContent || '' }
197+ ${ showBottomNavigation && styles . hasBottomNavigation || '' }
198+ ` } >
191199 < WCSigningRequest />
192200 < Aopp />
193201 < KeystoreConnectPrompt />
0 commit comments