mirror of
https://github.com/trezor/trezor-wallet
synced 2024-11-24 09:18:09 +00:00
getState().connect.devices replaced by getState().devices
This commit is contained in:
parent
977d9f3983
commit
3b452661c6
@ -17,7 +17,7 @@ import BigNumber from 'bignumber.js';
|
|||||||
import { initialState } from '../reducers/SendFormReducer';
|
import { initialState } from '../reducers/SendFormReducer';
|
||||||
import { findAccount } from '../reducers/AccountsReducer';
|
import { findAccount } from '../reducers/AccountsReducer';
|
||||||
import { findToken } from '../reducers/TokensReducer';
|
import { findToken } from '../reducers/TokensReducer';
|
||||||
import { findDevice } from '../reducers/TrezorConnectReducer';
|
import { findDevice } from '../reducers/DevicesReducer';
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
Dispatch,
|
Dispatch,
|
||||||
@ -282,11 +282,11 @@ export const validation = (): ThunkAction => {
|
|||||||
// corner-case: when same derivation path is used on different networks
|
// corner-case: when same derivation path is used on different networks
|
||||||
const currentNetworkAccount = savedAccounts.find(a => a.network === accountState.network);
|
const currentNetworkAccount = savedAccounts.find(a => a.network === accountState.network);
|
||||||
if (currentNetworkAccount) {
|
if (currentNetworkAccount) {
|
||||||
const device: ?TrezorDevice = findDevice(getState().connect.devices, currentNetworkAccount.deviceID, currentNetworkAccount.deviceState);
|
const device: ?TrezorDevice = findDevice(getState().devices, currentNetworkAccount.deviceID, currentNetworkAccount.deviceState);
|
||||||
if (!device) return;
|
if (!device) return;
|
||||||
infos.address = `${ device.instanceLabel } Account #${ (currentNetworkAccount.index + 1) }`;
|
infos.address = `${ device.instanceLabel } Account #${ (currentNetworkAccount.index + 1) }`;
|
||||||
} else {
|
} else {
|
||||||
const device: ?TrezorDevice = findDevice(getState().connect.devices, savedAccounts[0].deviceID, savedAccounts[0].deviceState);
|
const device: ?TrezorDevice = findDevice(getState().devices, savedAccounts[0].deviceID, savedAccounts[0].deviceState);
|
||||||
if (!device) return;
|
if (!device) return;
|
||||||
warnings.address = `Looks like it's ${ device.instanceLabel } Account #${ (savedAccounts[0].index + 1) } address of ${ savedAccounts[0].network.toUpperCase() } network`;
|
warnings.address = `Looks like it's ${ device.instanceLabel } Account #${ (savedAccounts[0].index + 1) } address of ${ savedAccounts[0].network.toUpperCase() } network`;
|
||||||
}
|
}
|
||||||
|
@ -140,8 +140,7 @@ export const postInit = (): ThunkAction => {
|
|||||||
TrezorConnect.on(DEVICE.CONNECT, handleDeviceConnect);
|
TrezorConnect.on(DEVICE.CONNECT, handleDeviceConnect);
|
||||||
TrezorConnect.on(DEVICE.CONNECT_UNACQUIRED, handleDeviceConnect);
|
TrezorConnect.on(DEVICE.CONNECT_UNACQUIRED, handleDeviceConnect);
|
||||||
|
|
||||||
// const devices: Array<TrezorDevice> = getState().connect.devices;
|
const { devices } = getState();
|
||||||
const devices: Array<TrezorDevice> = getState().connect.devices;
|
|
||||||
|
|
||||||
const { initialPathname, initialParams } = getState().wallet;
|
const { initialPathname, initialParams } = getState().wallet;
|
||||||
|
|
||||||
@ -228,7 +227,7 @@ export const onSelectDevice = (device: TrezorDevice | Device): ThunkAction => {
|
|||||||
if (!device.hasOwnProperty('ts')) {
|
if (!device.hasOwnProperty('ts')) {
|
||||||
// its device from trezor-connect (called in initConnectedDevice triggered by device_connect event)
|
// its device from trezor-connect (called in initConnectedDevice triggered by device_connect event)
|
||||||
// need to lookup if there are unavailable instances
|
// need to lookup if there are unavailable instances
|
||||||
const available: Array<TrezorDevice> = getState().connect.devices.filter(d => d.path === device.path);
|
const available: Array<TrezorDevice> = getState().devices.filter(d => d.path === device.path);
|
||||||
const latest: Array<TrezorDevice> = sortDevices(available);
|
const latest: Array<TrezorDevice> = sortDevices(available);
|
||||||
|
|
||||||
if (latest.length > 0 && latest[0].instance) {
|
if (latest.length > 0 && latest[0].instance) {
|
||||||
@ -249,7 +248,7 @@ export const onSelectDevice = (device: TrezorDevice | Device): ThunkAction => {
|
|||||||
export const switchToFirstAvailableDevice = (): AsyncAction => {
|
export const switchToFirstAvailableDevice = (): AsyncAction => {
|
||||||
return async (dispatch: Dispatch, getState: GetState): Promise<void> => {
|
return async (dispatch: Dispatch, getState: GetState): Promise<void> => {
|
||||||
|
|
||||||
const { devices } = getState().connect;
|
const { devices } = getState();
|
||||||
if (devices.length > 0) {
|
if (devices.length > 0) {
|
||||||
// TODO: Priority:
|
// TODO: Priority:
|
||||||
// 1. First Unacquired
|
// 1. First Unacquired
|
||||||
@ -331,7 +330,7 @@ export const deviceDisconnect = (device: Device): AsyncAction => {
|
|||||||
dispatch( DiscoveryActions.stop(selected) );
|
dispatch( DiscoveryActions.stop(selected) );
|
||||||
}
|
}
|
||||||
|
|
||||||
const instances = getState().connect.devices.filter(d => d.features && d.state && !d.remember && d.features.device_id === device.features.device_id);
|
const instances = getState().devices.filter(d => d.features && d.state && !d.remember && d.features.device_id === device.features.device_id);
|
||||||
if (instances.length > 0) {
|
if (instances.length > 0) {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: CONNECT.REMEMBER_REQUEST,
|
type: CONNECT.REMEMBER_REQUEST,
|
||||||
|
@ -38,7 +38,8 @@ const BrowserNotSupported = (props: {}): React$Element<string> => {
|
|||||||
export default (props: Props) => {
|
export default (props: Props) => {
|
||||||
|
|
||||||
const web3 = props.web3;
|
const web3 = props.web3;
|
||||||
const { devices, browserState, transport } = props.connect;
|
const { devices } = props;
|
||||||
|
const { browserState, transport } = props.connect;
|
||||||
const localStorageError = props.localStorage.error;
|
const localStorageError = props.localStorage.error;
|
||||||
const connectError = props.connect.error;
|
const connectError = props.connect.error;
|
||||||
|
|
||||||
|
@ -16,7 +16,9 @@ export type StateProps = {
|
|||||||
web3: $ElementType<State, 'web3'>,
|
web3: $ElementType<State, 'web3'>,
|
||||||
wallet: $ElementType<State, 'wallet'>,
|
wallet: $ElementType<State, 'wallet'>,
|
||||||
connect: $ElementType<State, 'connect'>,
|
connect: $ElementType<State, 'connect'>,
|
||||||
router: $ElementType<State, 'router'>
|
router: $ElementType<State, 'router'>,
|
||||||
|
wallet: $ElementType<State, 'wallet'>,
|
||||||
|
devices: $ElementType<State, 'devices'>,
|
||||||
}
|
}
|
||||||
|
|
||||||
type DispatchProps = {
|
type DispatchProps = {
|
||||||
@ -36,7 +38,9 @@ const mapStateToProps: MapStateToProps<State, OwnProps, StateProps> = (state: St
|
|||||||
web3: state.web3,
|
web3: state.web3,
|
||||||
wallet: state.wallet,
|
wallet: state.wallet,
|
||||||
connect: state.connect,
|
connect: state.connect,
|
||||||
router: state.router
|
router: state.router,
|
||||||
|
wallet: state.wallet,
|
||||||
|
devices: state.devices,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { getNewInstance } from '~/js/reducers/TrezorConnectReducer'
|
import { getNewInstance } from '~/js/reducers/DevicesReducer'
|
||||||
import type { Props } from './index';
|
import type { Props } from './index';
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
@ -24,7 +24,7 @@ export default class DuplicateDevice extends Component<Props, State> {
|
|||||||
const device = props.modal.opened ? props.modal.device : null;
|
const device = props.modal.opened ? props.modal.device : null;
|
||||||
if (!device) return;
|
if (!device) return;
|
||||||
|
|
||||||
const instance = getNewInstance(props.connect.devices, device);
|
const instance = getNewInstance(props.devices, device);
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
defaultName: `${device.label} (${instance.toString()})`,
|
defaultName: `${device.label} (${instance.toString()})`,
|
||||||
@ -57,7 +57,7 @@ export default class DuplicateDevice extends Component<Props, State> {
|
|||||||
|
|
||||||
let isUsed: boolean = false;
|
let isUsed: boolean = false;
|
||||||
if (value.length > 0) {
|
if (value.length > 0) {
|
||||||
isUsed = ( this.props.connect.devices.find(d => d.instanceName === value) !== undefined );
|
isUsed = ( this.props.devices.find(d => d.instanceName === value) !== undefined );
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@ -31,9 +31,8 @@ export default class PinModal extends Component<Props, State> {
|
|||||||
if (!device) return;
|
if (!device) return;
|
||||||
|
|
||||||
// check if this device is already known
|
// check if this device is already known
|
||||||
// const isSavedDevice = props.devices.find(d => d.path === props.modal.device.path && d.remember);
|
|
||||||
const selected = props.wallet.selectedDevice;
|
const selected = props.wallet.selectedDevice;
|
||||||
let deviceLabel =device.label;
|
let deviceLabel = device.label;
|
||||||
let singleInput = false;
|
let singleInput = false;
|
||||||
if (selected && selected.path === device.path) {
|
if (selected && selected.path === device.path) {
|
||||||
deviceLabel = selected.instanceLabel;
|
deviceLabel = selected.instanceLabel;
|
||||||
|
@ -34,7 +34,7 @@ type OwnProps = { }
|
|||||||
type StateProps = {
|
type StateProps = {
|
||||||
modal: $ElementType<State, 'modal'>,
|
modal: $ElementType<State, 'modal'>,
|
||||||
accounts: $ElementType<State, 'accounts'>,
|
accounts: $ElementType<State, 'accounts'>,
|
||||||
devices: $PropertyType<$ElementType<State, 'connect'>, 'devices'>,
|
devices: $ElementType<State, 'devices'>,
|
||||||
connect: $ElementType<State, 'connect'>,
|
connect: $ElementType<State, 'connect'>,
|
||||||
selectedAccount: $ElementType<State, 'selectedAccount'>,
|
selectedAccount: $ElementType<State, 'selectedAccount'>,
|
||||||
sendForm: $ElementType<State, 'sendForm'>,
|
sendForm: $ElementType<State, 'sendForm'>,
|
||||||
@ -127,7 +127,7 @@ const mapStateToProps: MapStateToProps<State, OwnProps, StateProps> = (state: St
|
|||||||
return {
|
return {
|
||||||
modal: state.modal,
|
modal: state.modal,
|
||||||
accounts: state.accounts,
|
accounts: state.accounts,
|
||||||
devices: state.connect.devices,
|
devices: state.devices,
|
||||||
connect: state.connect,
|
connect: state.connect,
|
||||||
selectedAccount: state.selectedAccount,
|
selectedAccount: state.selectedAccount,
|
||||||
sendForm: state.sendForm,
|
sendForm: state.sendForm,
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { Notification } from '~/js/components/common/Notification';
|
import { Notification } from '~/js/components/common/Notification';
|
||||||
import { findDevice } from '~/js/reducers/TrezorConnectReducer';
|
import { findDevice } from '~/js/reducers/DevicesReducer';
|
||||||
|
|
||||||
// import * as SelectedAccountActions from '~/js/actions/SelectedAccountActions';
|
// import * as SelectedAccountActions from '~/js/actions/SelectedAccountActions';
|
||||||
import { default as SelectedAccountActions } from '~/js/actions/SelectedAccountActions';
|
import { default as SelectedAccountActions } from '~/js/actions/SelectedAccountActions';
|
||||||
@ -14,7 +14,7 @@ import type { Discovery } from '~/js/reducers/DiscoveryReducer';
|
|||||||
|
|
||||||
export type StateProps = {
|
export type StateProps = {
|
||||||
selectedAccount: $ElementType<State, 'selectedAccount'>,
|
selectedAccount: $ElementType<State, 'selectedAccount'>,
|
||||||
devices: $PropertyType<$ElementType<State, 'connect'>, 'devices'>,
|
devices: $ElementType<State, 'devices'>,
|
||||||
discovery: $ElementType<State, 'discovery'>,
|
discovery: $ElementType<State, 'discovery'>,
|
||||||
accounts: $ElementType<State, 'accounts'>,
|
accounts: $ElementType<State, 'accounts'>,
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ export type Props = StateProps & DispatchProps;
|
|||||||
const mapStateToProps: MapStateToProps<State, OwnProps, StateProps> = (state: State, own: OwnProps): StateProps => {
|
const mapStateToProps: MapStateToProps<State, OwnProps, StateProps> = (state: State, own: OwnProps): StateProps => {
|
||||||
return {
|
return {
|
||||||
selectedAccount: state.selectedAccount,
|
selectedAccount: state.selectedAccount,
|
||||||
devices: state.connect.devices,
|
devices: state.devices,
|
||||||
accounts: state.accounts,
|
accounts: state.accounts,
|
||||||
discovery: state.discovery,
|
discovery: state.discovery,
|
||||||
receive: state.receive,
|
receive: state.receive,
|
||||||
|
@ -33,7 +33,7 @@ export type Props = StateProps & DispatchProps;
|
|||||||
const mapStateToProps: MapStateToProps<State, OwnProps, StateProps> = (state: State, own: OwnProps): StateProps => {
|
const mapStateToProps: MapStateToProps<State, OwnProps, StateProps> = (state: State, own: OwnProps): StateProps => {
|
||||||
return {
|
return {
|
||||||
selectedAccount: state.selectedAccount,
|
selectedAccount: state.selectedAccount,
|
||||||
devices: state.connect.devices,
|
devices: state.devices,
|
||||||
accounts: state.accounts,
|
accounts: state.accounts,
|
||||||
discovery: state.discovery,
|
discovery: state.discovery,
|
||||||
tokens: state.tokens,
|
tokens: state.tokens,
|
||||||
|
@ -35,7 +35,7 @@ export type Props = StateProps & DispatchProps;
|
|||||||
const mapStateToProps: MapStateToProps<State, OwnProps, StateProps> = (state: State, own: OwnProps): StateProps => {
|
const mapStateToProps: MapStateToProps<State, OwnProps, StateProps> = (state: State, own: OwnProps): StateProps => {
|
||||||
return {
|
return {
|
||||||
selectedAccount: state.selectedAccount,
|
selectedAccount: state.selectedAccount,
|
||||||
devices: state.connect.devices,
|
devices: state.devices,
|
||||||
accounts: state.accounts,
|
accounts: state.accounts,
|
||||||
discovery: state.discovery,
|
discovery: state.discovery,
|
||||||
|
|
||||||
|
@ -10,11 +10,11 @@ import type { TrezorDevice } from '~/flowtype';
|
|||||||
const CoinSelection = (props: Props): React$Element<string> => {
|
const CoinSelection = (props: Props): React$Element<string> => {
|
||||||
const { location } = props.router;
|
const { location } = props.router;
|
||||||
const { config } = props.localStorage;
|
const { config } = props.localStorage;
|
||||||
const selectedDevice = props.connect.selectedDevice;
|
const { selectedDevice } = props.wallet;
|
||||||
|
|
||||||
let baseUrl: string = '';
|
let baseUrl: string = '';
|
||||||
if (selectedDevice) {
|
if (selectedDevice && selectedDevice.features) {
|
||||||
baseUrl = `/device/${selectedDevice.id}`;
|
baseUrl = `/device/${selectedDevice.features.device_id}`;
|
||||||
if (selectedDevice.instance) {
|
if (selectedDevice.instance) {
|
||||||
baseUrl += `:${selectedDevice.instance}`;
|
baseUrl += `:${selectedDevice.instance}`;
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,8 @@ import type { TrezorDevice } from '~/flowtype';
|
|||||||
|
|
||||||
export const DeviceSelect = (props: Props) => {
|
export const DeviceSelect = (props: Props) => {
|
||||||
|
|
||||||
const { devices, transport } = props.connect;
|
const { devices } = props;
|
||||||
|
const { transport } = props.connect;
|
||||||
|
|
||||||
const selected: ?TrezorDevice = props.wallet.selectedDevice;
|
const selected: ?TrezorDevice = props.wallet.selectedDevice;
|
||||||
if (!selected) return null;
|
if (!selected) return null;
|
||||||
@ -136,7 +137,8 @@ export class DeviceDropdown extends Component<Props> {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
||||||
const { devices, transport } = this.props.connect;
|
const { devices } = this.props;
|
||||||
|
const { transport } = this.props.connect;
|
||||||
const selected: ?TrezorDevice = this.props.wallet.selectedDevice;
|
const selected: ?TrezorDevice = this.props.wallet.selectedDevice;
|
||||||
if (!selected) return;
|
if (!selected) return;
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ type StateProps = {
|
|||||||
localStorage: $ElementType<State, 'localStorage'>,
|
localStorage: $ElementType<State, 'localStorage'>,
|
||||||
discovery: $ElementType<State, 'discovery'>,
|
discovery: $ElementType<State, 'discovery'>,
|
||||||
wallet: $ElementType<State, 'wallet'>,
|
wallet: $ElementType<State, 'wallet'>,
|
||||||
|
devices: $ElementType<State, 'devices'>,
|
||||||
}
|
}
|
||||||
|
|
||||||
type DispatchProps = {
|
type DispatchProps = {
|
||||||
@ -50,7 +51,8 @@ const mapStateToProps: MapStateToProps<State, OwnProps, StateProps> = (state: St
|
|||||||
fiat: state.fiat,
|
fiat: state.fiat,
|
||||||
localStorage: state.localStorage,
|
localStorage: state.localStorage,
|
||||||
discovery: state.discovery,
|
discovery: state.discovery,
|
||||||
wallet: state.wallet
|
wallet: state.wallet,
|
||||||
|
devices: state.devices
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ const findPendingTxs = (accounts: Array<Account>, pending: Array<PendingTx>): Ar
|
|||||||
}
|
}
|
||||||
|
|
||||||
const save = (dispatch: Dispatch, getState: GetState): void => {
|
const save = (dispatch: Dispatch, getState: GetState): void => {
|
||||||
const devices: Array<TrezorDevice> = getState().connect.devices.filter(d => d.features && d.remember === true);
|
const devices: Array<TrezorDevice> = getState().devices.filter(d => d.features && d.remember === true);
|
||||||
const accounts: Array<Account> = findAccounts(devices, getState().accounts);
|
const accounts: Array<Account> = findAccounts(devices, getState().accounts);
|
||||||
const tokens: Array<Token> = findTokens(accounts, getState().tokens);
|
const tokens: Array<Token> = findTokens(accounts, getState().tokens);
|
||||||
const pending: Array<PendingTx> = findPendingTxs(accounts, getState().pending);
|
const pending: Array<PendingTx> = findPendingTxs(accounts, getState().pending);
|
||||||
|
@ -48,7 +48,7 @@ const pathToParams = (path: string): RouterLocationState => {
|
|||||||
const validation = (api: MiddlewareAPI, params: RouterLocationState): boolean => {
|
const validation = (api: MiddlewareAPI, params: RouterLocationState): boolean => {
|
||||||
|
|
||||||
if (params.hasOwnProperty('device')) {
|
if (params.hasOwnProperty('device')) {
|
||||||
const { devices } = api.getState().connect;
|
const { devices } = api.getState();
|
||||||
|
|
||||||
let device: ?TrezorDevice;
|
let device: ?TrezorDevice;
|
||||||
if (params.hasOwnProperty('deviceInstance')) {
|
if (params.hasOwnProperty('deviceInstance')) {
|
||||||
@ -89,7 +89,8 @@ const RouterService: Middleware = (api: MiddlewareAPI) => (next: MiddlewareDispa
|
|||||||
|
|
||||||
const { location } = api.getState().router;
|
const { location } = api.getState().router;
|
||||||
const web3 = api.getState().web3;
|
const web3 = api.getState().web3;
|
||||||
const { devices, error } = api.getState().connect;
|
const { devices } = api.getState();
|
||||||
|
const { error } = api.getState().connect;
|
||||||
|
|
||||||
const requestedParams: RouterLocationState = pathToParams(action.payload.pathname);
|
const requestedParams: RouterLocationState = pathToParams(action.payload.pathname);
|
||||||
const currentParams: RouterLocationState = pathToParams(location ? location.pathname : '/');
|
const currentParams: RouterLocationState = pathToParams(location ? location.pathname : '/');
|
||||||
|
@ -62,7 +62,7 @@ const TrezorConnectService: Middleware = (api: MiddlewareAPI) => (next: Middlewa
|
|||||||
//api.dispatch( TrezorConnectActions.forgetDevice(action.device) );
|
//api.dispatch( TrezorConnectActions.forgetDevice(action.device) );
|
||||||
api.dispatch( TrezorConnectActions.switchToFirstAvailableDevice() );
|
api.dispatch( TrezorConnectActions.switchToFirstAvailableDevice() );
|
||||||
} else if (action.type === CONNECT.FORGET_SINGLE) {
|
} else if (action.type === CONNECT.FORGET_SINGLE) {
|
||||||
if (api.getState().connect.devices.length < 1 && action.device.connected) {
|
if (api.getState().devices.length < 1 && action.device.connected) {
|
||||||
// prompt disconnect device info in LandingPage
|
// prompt disconnect device info in LandingPage
|
||||||
api.dispatch({
|
api.dispatch({
|
||||||
type: CONNECT.DISCONNECT_REQUEST,
|
type: CONNECT.DISCONNECT_REQUEST,
|
||||||
@ -81,8 +81,6 @@ const TrezorConnectService: Middleware = (api: MiddlewareAPI) => (next: Middlewa
|
|||||||
api.dispatch( DiscoveryActions.check() );
|
api.dispatch( DiscoveryActions.check() );
|
||||||
} else if (action.type === CONNECT.DUPLICATE) {
|
} else if (action.type === CONNECT.DUPLICATE) {
|
||||||
api.dispatch( TrezorConnectActions.onSelectDevice( action.device ) );
|
api.dispatch( TrezorConnectActions.onSelectDevice( action.device ) );
|
||||||
// } else if (action.type === CONNECT.SELECT_DEVICE) {
|
|
||||||
// api.dispatch( TrezorConnectActions.getSelectedDeviceState() );
|
|
||||||
} else if (action.type === CONNECT.COIN_CHANGED) {
|
} else if (action.type === CONNECT.COIN_CHANGED) {
|
||||||
api.dispatch( TrezorConnectActions.coinChanged( action.payload.network ) );
|
api.dispatch( TrezorConnectActions.coinChanged( action.payload.network ) );
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ const getSelectedDevice = (state: State): ?TrezorDevice => {
|
|||||||
if (!locationState.device) return undefined;
|
if (!locationState.device) return undefined;
|
||||||
|
|
||||||
const instance: ?number = locationState.deviceInstance ? parseInt(locationState.deviceInstance) : undefined;
|
const instance: ?number = locationState.deviceInstance ? parseInt(locationState.deviceInstance) : undefined;
|
||||||
return state.connect.devices.find(d => {
|
return state.devices.find(d => {
|
||||||
if (d.unacquired && d.path === locationState.device) {
|
if (d.unacquired && d.path === locationState.device) {
|
||||||
return true;
|
return true;
|
||||||
} else if (d.features && d.features.bootloader_mode && d.path === locationState.device) {
|
} else if (d.features && d.features.bootloader_mode && d.path === locationState.device) {
|
||||||
@ -61,7 +61,7 @@ const WalletService: Middleware = (api: MiddlewareAPI) => (next: MiddlewareDispa
|
|||||||
const state = api.getState();
|
const state = api.getState();
|
||||||
|
|
||||||
// handle devices state change
|
// handle devices state change
|
||||||
if (locationChange || prevState.connect.devices !== state.connect.devices) {
|
if (locationChange || prevState.devices !== state.devices) {
|
||||||
const device = getSelectedDevice(state);
|
const device = getSelectedDevice(state);
|
||||||
const currentDevice = state.wallet.selectedDevice;
|
const currentDevice = state.wallet.selectedDevice;
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ const WalletService: Middleware = (api: MiddlewareAPI) => (next: MiddlewareDispa
|
|||||||
type: WALLET.SET_SELECTED_DEVICE,
|
type: WALLET.SET_SELECTED_DEVICE,
|
||||||
device
|
device
|
||||||
});
|
});
|
||||||
|
|
||||||
if (device) {
|
if (device) {
|
||||||
api.dispatch( TrezorConnectActions.getSelectedDeviceState() );
|
api.dispatch( TrezorConnectActions.getSelectedDeviceState() );
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user