mirror of
https://github.com/trezor/trezor-wallet
synced 2024-11-24 09:18:09 +00:00
renamed "acquiring" to "acquiringDevice" in connect reducer
This commit is contained in:
parent
49aa31774e
commit
2e4acf3ee8
@ -71,9 +71,7 @@ export type TrezorConnectAction = {
|
||||
type: typeof CONNECT.DEVICE_FROM_STORAGE,
|
||||
payload: Array<TrezorDevice>
|
||||
} | {
|
||||
type: typeof CONNECT.START_ACQUIRING,
|
||||
} | {
|
||||
type: typeof CONNECT.STOP_ACQUIRING,
|
||||
type: typeof CONNECT.START_ACQUIRING | typeof CONNECT.STOP_ACQUIRING,
|
||||
};
|
||||
|
||||
export const init = (): AsyncAction => async (dispatch: Dispatch, getState: GetState): Promise<void> => {
|
||||
@ -128,10 +126,10 @@ export const init = (): AsyncAction => async (dispatch: Dispatch, getState: GetS
|
||||
pendingTransportEvent: (getState().devices.length < 1),
|
||||
});
|
||||
} catch (error) {
|
||||
// dispatch({
|
||||
// type: CONNECT.INITIALIZATION_ERROR,
|
||||
// error
|
||||
// })
|
||||
dispatch({
|
||||
type: CONNECT.INITIALIZATION_ERROR,
|
||||
error,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -94,7 +94,6 @@ const addDevice = (state: State, device: Device): State => {
|
||||
|
||||
const newDevice: TrezorDevice = device.type === 'acquired' ? {
|
||||
...device,
|
||||
// acquiring: false,
|
||||
...extended,
|
||||
} : {
|
||||
...device,
|
||||
@ -154,7 +153,6 @@ const duplicate = (state: State, device: TrezorDevice): State => {
|
||||
|
||||
const newDevice: TrezorDevice = {
|
||||
...device,
|
||||
// acquiring: false,
|
||||
remember: false,
|
||||
state: null,
|
||||
// instance, (instance is already part of device - added in modal)
|
||||
|
@ -10,9 +10,7 @@ export type SelectedDevice = {
|
||||
}
|
||||
|
||||
export type State = {
|
||||
// devices: Array<TrezorDevice>;
|
||||
// selectedDevice: ?SelectedDevice;
|
||||
discoveryComplete: boolean;
|
||||
initialized: boolean;
|
||||
error: ?string;
|
||||
transport: ?{
|
||||
type: string;
|
||||
@ -26,54 +24,42 @@ export type State = {
|
||||
// mobile: boolean;
|
||||
// } | {};
|
||||
browserState: any;
|
||||
acquiring: boolean;
|
||||
acquiringDevice: boolean;
|
||||
}
|
||||
|
||||
|
||||
const initialState: State = {
|
||||
// devices: [],
|
||||
//selectedDevice: null,
|
||||
discoveryComplete: false,
|
||||
initialized: false,
|
||||
error: null,
|
||||
transport: null,
|
||||
browserState: {},
|
||||
acquiring: false,
|
||||
acquiringDevice: false,
|
||||
};
|
||||
|
||||
|
||||
export default function connect(state: State = initialState, action: Action): State {
|
||||
switch (action.type) {
|
||||
case UI.IFRAME_HANDSHAKE:
|
||||
return {
|
||||
...state,
|
||||
browserState: action.payload.browser,
|
||||
};
|
||||
|
||||
case CONNECT.START_ACQUIRING:
|
||||
return {
|
||||
...state,
|
||||
acquiring: true,
|
||||
};
|
||||
|
||||
case CONNECT.STOP_ACQUIRING:
|
||||
return {
|
||||
...state,
|
||||
acquiring: false,
|
||||
};
|
||||
|
||||
// trezor-connect iframe didn't loaded properly
|
||||
case CONNECT.INITIALIZATION_ERROR:
|
||||
return {
|
||||
...state,
|
||||
error: action.error,
|
||||
};
|
||||
|
||||
// trezor-connect iframe loaded
|
||||
case UI.IFRAME_HANDSHAKE:
|
||||
return {
|
||||
...state,
|
||||
initialized: true,
|
||||
browserState: action.payload.browser,
|
||||
};
|
||||
// trezor-connect (trezor-link) initialized
|
||||
case TRANSPORT.START:
|
||||
return {
|
||||
...state,
|
||||
transport: action.payload,
|
||||
error: null,
|
||||
};
|
||||
|
||||
// trezor-connect (trezor-link)
|
||||
// will be called continuously in interval until connection (bridge/webusb) will be established
|
||||
case TRANSPORT.ERROR:
|
||||
return {
|
||||
...state,
|
||||
@ -82,6 +68,17 @@ export default function connect(state: State = initialState, action: Action): St
|
||||
transport: null,
|
||||
};
|
||||
|
||||
case CONNECT.START_ACQUIRING:
|
||||
return {
|
||||
...state,
|
||||
acquiringDevice: true,
|
||||
};
|
||||
|
||||
case CONNECT.STOP_ACQUIRING:
|
||||
return {
|
||||
...state,
|
||||
acquiringDevice: false,
|
||||
};
|
||||
|
||||
default:
|
||||
return state;
|
||||
|
@ -46,7 +46,7 @@ const Acquire = (props: Props) => {
|
||||
|
||||
export default connect(
|
||||
(state: State) => ({
|
||||
acquiring: state.connect.acquiring,
|
||||
acquiring: state.connect.acquiringDevice,
|
||||
}),
|
||||
(dispatch: Dispatch) => ({
|
||||
acquireDevice: bindActionCreators(TrezorConnectActions.acquire, dispatch),
|
||||
|
@ -23,11 +23,4 @@ const UnreadableDevice = () => (
|
||||
</Wrapper>
|
||||
);
|
||||
|
||||
export default connect(
|
||||
(state: State) => ({
|
||||
acquiring: state.connect.acquiring,
|
||||
}),
|
||||
(dispatch: Dispatch) => ({
|
||||
acquireDevice: bindActionCreators(TrezorConnectActions.acquire, dispatch),
|
||||
}),
|
||||
)(UnreadableDevice);
|
||||
export default connect(null, null)(UnreadableDevice);
|
||||
|
Loading…
Reference in New Issue
Block a user