mirror of
https://github.com/trezor/trezor-wallet
synced 2024-11-24 09:18:09 +00:00
FORGET_SILENT if disconnected device is not selected and modal is opened
This commit is contained in:
parent
a357c7dc8c
commit
14eac38246
@ -6,6 +6,7 @@ import * as CONNECT from 'actions/constants/TrezorConnect';
|
|||||||
import * as NOTIFICATION from 'actions/constants/notification';
|
import * as NOTIFICATION from 'actions/constants/notification';
|
||||||
import { getDuplicateInstanceNumber } from 'reducers/utils';
|
import { getDuplicateInstanceNumber } from 'reducers/utils';
|
||||||
import * as RouterActions from 'actions/RouterActions';
|
import * as RouterActions from 'actions/RouterActions';
|
||||||
|
import * as deviceUtils from 'utils/device';
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
DeviceMessage,
|
DeviceMessage,
|
||||||
@ -58,7 +59,7 @@ export type TrezorConnectAction = {
|
|||||||
type: typeof CONNECT.FORGET,
|
type: typeof CONNECT.FORGET,
|
||||||
device: TrezorDevice
|
device: TrezorDevice
|
||||||
} | {
|
} | {
|
||||||
type: typeof CONNECT.FORGET_SINGLE,
|
type: typeof CONNECT.FORGET_SINGLE | typeof CONNECT.FORGET_SILENT,
|
||||||
device: TrezorDevice
|
device: TrezorDevice
|
||||||
} | {
|
} | {
|
||||||
type: typeof CONNECT.REMEMBER,
|
type: typeof CONNECT.REMEMBER,
|
||||||
@ -222,11 +223,19 @@ export const deviceDisconnect = (device: Device): AsyncAction => async (dispatch
|
|||||||
if (device.features) {
|
if (device.features) {
|
||||||
const instances = getState().devices.filter(d => d.features && device.features && d.state && !d.remember && d.features.device_id === device.features.device_id);
|
const instances = getState().devices.filter(d => d.features && device.features && d.state && !d.remember && d.features.device_id === device.features.device_id);
|
||||||
if (instances.length > 0) {
|
if (instances.length > 0) {
|
||||||
dispatch({
|
const isSelected = deviceUtils.isSelectedDevice(getState().wallet.selectedDevice, instances[0]);
|
||||||
type: CONNECT.REMEMBER_REQUEST,
|
if (!isSelected && getState().modal.opened) {
|
||||||
device: instances[0],
|
dispatch({
|
||||||
instances,
|
type: CONNECT.FORGET_SILENT,
|
||||||
});
|
device: instances[0],
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
dispatch({
|
||||||
|
type: CONNECT.REMEMBER_REQUEST,
|
||||||
|
device: instances[0],
|
||||||
|
instances,
|
||||||
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
dispatch(RouterActions.selectFirstAvailableDevice());
|
dispatch(RouterActions.selectFirstAvailableDevice());
|
||||||
}
|
}
|
||||||
@ -291,12 +300,7 @@ export const forget = (device: TrezorDevice): Action => ({
|
|||||||
device,
|
device,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const duplicateDevice1 = (device: TrezorDevice): AsyncAction => async (dispatch: Dispatch, getState: GetState): Promise<void> => {
|
export const duplicateDeviceOld = (device: TrezorDevice): AsyncAction => async (dispatch: Dispatch, getState: GetState): Promise<void> => {
|
||||||
// dispatch({
|
|
||||||
// type: CONNECT.TRY_TO_DUPLICATE,
|
|
||||||
// device,
|
|
||||||
// });
|
|
||||||
|
|
||||||
const instance: number = getDuplicateInstanceNumber(getState().devices, device);
|
const instance: number = getDuplicateInstanceNumber(getState().devices, device);
|
||||||
const extended: Object = { instance };
|
const extended: Object = { instance };
|
||||||
dispatch({
|
dispatch({
|
||||||
@ -305,12 +309,7 @@ export const duplicateDevice1 = (device: TrezorDevice): AsyncAction => async (di
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const duplicateDevice = (device: TrezorDevice): AsyncAction => async (dispatch: Dispatch, getState: GetState): Promise<void> => {
|
export const duplicateDevice = (device: TrezorDevice): AsyncAction => async (dispatch: Dispatch): Promise<void> => {
|
||||||
// dispatch({
|
|
||||||
// type: CONNECT.TRY_TO_DUPLICATE,
|
|
||||||
// device,
|
|
||||||
// });
|
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
type: CONNECT.REQUEST_WALLET_TYPE,
|
type: CONNECT.REQUEST_WALLET_TYPE,
|
||||||
device,
|
device,
|
||||||
|
@ -16,6 +16,7 @@ export const REMEMBER_REQUEST: 'connect__remember_request' = 'connect__remember_
|
|||||||
export const FORGET_REQUEST: 'connect__forget_request' = 'connect__forget_request';
|
export const FORGET_REQUEST: 'connect__forget_request' = 'connect__forget_request';
|
||||||
export const FORGET: 'connect__forget' = 'connect__forget';
|
export const FORGET: 'connect__forget' = 'connect__forget';
|
||||||
export const FORGET_SINGLE: 'connect__forget_single' = 'connect__forget_single';
|
export const FORGET_SINGLE: 'connect__forget_single' = 'connect__forget_single';
|
||||||
|
export const FORGET_SILENT: 'connect__forget_silent' = 'connect__forget_silent';
|
||||||
export const DISCONNECT_REQUEST: 'connect__disconnect_request' = 'connect__disconnect_request';
|
export const DISCONNECT_REQUEST: 'connect__disconnect_request' = 'connect__disconnect_request';
|
||||||
export const REMEMBER: 'connect__remember' = 'connect__remember';
|
export const REMEMBER: 'connect__remember' = 'connect__remember';
|
||||||
|
|
||||||
|
@ -271,6 +271,7 @@ const onChangeWalletType = (state: State, device: TrezorDevice, hidden: boolean)
|
|||||||
...d,
|
...d,
|
||||||
state: null,
|
state: null,
|
||||||
useEmptyPassphrase: !hidden,
|
useEmptyPassphrase: !hidden,
|
||||||
|
ts: new Date().getTime(),
|
||||||
} : d;
|
} : d;
|
||||||
});
|
});
|
||||||
return otherDevices.concat(changedDevices);
|
return otherDevices.concat(changedDevices);
|
||||||
@ -296,6 +297,7 @@ export default function devices(state: State = initialState, action: Action): St
|
|||||||
case CONNECT.FORGET:
|
case CONNECT.FORGET:
|
||||||
return forgetDevice(state, action.device);
|
return forgetDevice(state, action.device);
|
||||||
case CONNECT.FORGET_SINGLE:
|
case CONNECT.FORGET_SINGLE:
|
||||||
|
case CONNECT.FORGET_SILENT:
|
||||||
return forgetSingleDevice(state, action.device);
|
return forgetSingleDevice(state, action.device);
|
||||||
|
|
||||||
case DEVICE.CONNECT:
|
case DEVICE.CONNECT:
|
||||||
|
Loading…
Reference in New Issue
Block a user