mirror of
https://github.com/trezor/trezor-wallet
synced 2024-11-24 09:18:09 +00:00
START/STOP_ACQUIRING (Acquire page)
This commit is contained in:
parent
369ca892c0
commit
2b4592343e
@ -74,6 +74,10 @@ export type TrezorConnectAction = {
|
||||
} | {
|
||||
type: typeof CONNECT.DEVICE_FROM_STORAGE,
|
||||
payload: Array<TrezorDevice>
|
||||
} | {
|
||||
type: typeof CONNECT.START_ACQUIRING,
|
||||
} | {
|
||||
type: typeof CONNECT.STOP_ACQUIRING,
|
||||
};
|
||||
|
||||
|
||||
@ -366,6 +370,10 @@ export function acquire(): AsyncAction {
|
||||
const selected: ?TrezorDevice = getState().wallet.selectedDevice;
|
||||
if (!selected) return;
|
||||
|
||||
dispatch({
|
||||
type: CONNECT.START_ACQUIRING,
|
||||
})
|
||||
|
||||
const response = await TrezorConnect.getFeatures({
|
||||
device: {
|
||||
path: selected.path,
|
||||
@ -381,17 +389,21 @@ export function acquire(): AsyncAction {
|
||||
title: 'Acquire device error',
|
||||
message: response.payload.error,
|
||||
cancelable: true,
|
||||
actions: [
|
||||
{
|
||||
label: 'Try again',
|
||||
callback: () => {
|
||||
dispatch(acquire())
|
||||
}
|
||||
}
|
||||
]
|
||||
// actions: [
|
||||
// {
|
||||
// label: 'Try again',
|
||||
// callback: () => {
|
||||
// dispatch(acquire())
|
||||
// }
|
||||
// }
|
||||
// ]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
dispatch({
|
||||
type: CONNECT.STOP_ACQUIRING,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,3 +23,6 @@ export const TRY_TO_DUPLICATE: 'connect__try_to_duplicate' = 'connect__try_to_du
|
||||
export const DUPLICATE: 'connect__duplicate' = 'connect__duplicate';
|
||||
|
||||
export const DEVICE_STATE_EXCEPTION: 'connect__device_state_exception' = 'connect__device_state_exception';
|
||||
|
||||
export const START_ACQUIRING: 'connect__start_acquiring' = 'connect__start_acquiring';
|
||||
export const STOP_ACQUIRING: 'connect__stop_acquiring' = 'connect__stop_acquiring';
|
@ -9,13 +9,13 @@ import * as TrezorConnectActions from '~/js/actions/TrezorConnectActions';
|
||||
|
||||
import type { State, Dispatch } from '~/flowtype';
|
||||
type Props = {
|
||||
connect: $ElementType<State, 'connect'>,
|
||||
acquiring: boolean;
|
||||
acquireDevice: typeof TrezorConnectActions.acquire
|
||||
}
|
||||
|
||||
const Acquire = (props: Props) => {
|
||||
|
||||
const actions = [
|
||||
const actions = props.acquiring ? [] : [
|
||||
{
|
||||
label: 'Acquire device',
|
||||
callback: () => {
|
||||
@ -40,7 +40,7 @@ const Acquire = (props: Props) => {
|
||||
export default connect(
|
||||
(state: State) => {
|
||||
return {
|
||||
log: state.log
|
||||
acquiring: state.connect.acquiring
|
||||
};
|
||||
},
|
||||
(dispatch: Dispatch) => {
|
||||
|
@ -30,6 +30,7 @@ export type State = {
|
||||
// mobile: boolean;
|
||||
// } | {};
|
||||
browserState: any;
|
||||
acquiring: boolean;
|
||||
}
|
||||
|
||||
|
||||
@ -39,7 +40,8 @@ const initialState: State = {
|
||||
discoveryComplete: false,
|
||||
error: null,
|
||||
transport: null,
|
||||
browserState: {}
|
||||
browserState: {},
|
||||
acquiring: false,
|
||||
};
|
||||
|
||||
|
||||
@ -55,6 +57,17 @@ export default function connect(state: State = initialState, action: Action): St
|
||||
browserState: action.payload.browser
|
||||
}
|
||||
|
||||
case CONNECT.START_ACQUIRING :
|
||||
return {
|
||||
...state,
|
||||
acquiring: true
|
||||
}
|
||||
|
||||
case CONNECT.STOP_ACQUIRING :
|
||||
return {
|
||||
...state,
|
||||
acquiring: false
|
||||
}
|
||||
|
||||
case CONNECT.INITIALIZATION_ERROR :
|
||||
return {
|
||||
|
Loading…
Reference in New Issue
Block a user