From 0cfa1567cf645df88d4598cc981cbaaaffa4b2f4 Mon Sep 17 00:00:00 2001 From: Szymon Lesisz Date: Tue, 22 May 2018 14:16:18 +0200 Subject: [PATCH] not initialized device page --- src/js/actions/TrezorConnectActions.js | 4 +++- src/js/components/wallet/aside/Aside.js | 2 +- src/js/components/wallet/pages/Initialize.js | 16 ++++++++++++++++ src/js/reducers/TrezorConnectReducer.js | 4 +++- src/js/router/index.js | 2 ++ 5 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 src/js/components/wallet/pages/Initialize.js diff --git a/src/js/actions/TrezorConnectActions.js b/src/js/actions/TrezorConnectActions.js index e0b67d9a..2a44d11d 100644 --- a/src/js/actions/TrezorConnectActions.js +++ b/src/js/actions/TrezorConnectActions.js @@ -220,6 +220,8 @@ export const onSelectDevice = (device: TrezorDevice | Device): ThunkAction => { dispatch( push(`/device/${ device.path }/acquire`) ); } else if (device.features.bootloader_mode) { dispatch( push(`/device/${ device.path }/bootloader`) ); + } else if (!device.features.initialized) { + dispatch( push(`/device/${ device.features.device_id }/initialize`) ); } else if (typeof device.instance === 'number') { dispatch( push(`/device/${ device.features.device_id }:${ device.instance }`) ); } else { @@ -284,7 +286,7 @@ export const getSelectedDeviceState = (): AsyncAction => { const selected = findSelectedDevice(getState().connect); if (selected && selected.connected - && selected.features + && (selected.features && !selected.features.bootloader_mode && selected.features.initialized) && !selected.state) { const response = await TrezorConnect.getDeviceState({ diff --git a/src/js/components/wallet/aside/Aside.js b/src/js/components/wallet/aside/Aside.js index 78bda006..c6a03a02 100644 --- a/src/js/components/wallet/aside/Aside.js +++ b/src/js/components/wallet/aside/Aside.js @@ -56,7 +56,7 @@ const Aside = (props: Props): React$Element => ); - } else if (!selected.unacquired) { + } else if (selected.features && !selected.features.bootloader_mode && selected.features.initialized) { menu = ( diff --git a/src/js/components/wallet/pages/Initialize.js b/src/js/components/wallet/pages/Initialize.js new file mode 100644 index 00000000..45cbf977 --- /dev/null +++ b/src/js/components/wallet/pages/Initialize.js @@ -0,0 +1,16 @@ +/* @flow */ +'use strict'; + +import React from 'react'; +import { bindActionCreators } from 'redux'; +import { connect } from 'react-redux'; + +const Initialize = () => { + return ( +
+

Device not initialized

+
+ ); +} + +export default connect(null, null)(Initialize); diff --git a/src/js/reducers/TrezorConnectReducer.js b/src/js/reducers/TrezorConnectReducer.js index 8b311aa9..6d1250e9 100644 --- a/src/js/reducers/TrezorConnectReducer.js +++ b/src/js/reducers/TrezorConnectReducer.js @@ -48,7 +48,9 @@ export const findSelectedDevice = (state: State): ?TrezorDevice => { return state.devices.find(d => { if (d.unacquired && d.path === selected.id) { return true; - } else if (d.features && d.features.device_id === selected.id && d.instance === selected.instance){ + } else if (d.features && d.features.bootloader_mode && d.path === selected.id) { + return true; + } else if (d.features && d.features.device_id === selected.id && d.instance === selected.instance) { return true; } return false; diff --git a/src/js/router/index.js b/src/js/router/index.js index a6355e00..378037f6 100644 --- a/src/js/router/index.js +++ b/src/js/router/index.js @@ -10,6 +10,7 @@ import store, { history } from '../store'; import LandingPageContainer from '../components/landing'; import WalletContainer from '../components/wallet'; import BootloaderContainer from '../components/wallet/pages/Bootloader'; +import InitializeContainer from '../components/wallet/pages/Initialize'; import AcquireContainer from '../components/wallet/pages/Acquire'; import DashboardContainer from '../components/wallet/pages/Dashboard'; @@ -34,6 +35,7 @@ export default ( +