mirror of
https://github.com/trezor/trezor-wallet
synced 2024-11-13 20:08:56 +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 { getDuplicateInstanceNumber } from 'reducers/utils';
|
||||
import * as RouterActions from 'actions/RouterActions';
|
||||
import * as deviceUtils from 'utils/device';
|
||||
|
||||
import type {
|
||||
DeviceMessage,
|
||||
@ -58,7 +59,7 @@ export type TrezorConnectAction = {
|
||||
type: typeof CONNECT.FORGET,
|
||||
device: TrezorDevice
|
||||
} | {
|
||||
type: typeof CONNECT.FORGET_SINGLE,
|
||||
type: typeof CONNECT.FORGET_SINGLE | typeof CONNECT.FORGET_SILENT,
|
||||
device: TrezorDevice
|
||||
} | {
|
||||
type: typeof CONNECT.REMEMBER,
|
||||
@ -222,11 +223,19 @@ export const deviceDisconnect = (device: Device): AsyncAction => async (dispatch
|
||||
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);
|
||||
if (instances.length > 0) {
|
||||
dispatch({
|
||||
type: CONNECT.REMEMBER_REQUEST,
|
||||
device: instances[0],
|
||||
instances,
|
||||
});
|
||||
const isSelected = deviceUtils.isSelectedDevice(getState().wallet.selectedDevice, instances[0]);
|
||||
if (!isSelected && getState().modal.opened) {
|
||||
dispatch({
|
||||
type: CONNECT.FORGET_SILENT,
|
||||
device: instances[0],
|
||||
});
|
||||
} else {
|
||||
dispatch({
|
||||
type: CONNECT.REMEMBER_REQUEST,
|
||||
device: instances[0],
|
||||
instances,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
dispatch(RouterActions.selectFirstAvailableDevice());
|
||||
}
|
||||
@ -291,12 +300,7 @@ export const forget = (device: TrezorDevice): Action => ({
|
||||
device,
|
||||
});
|
||||
|
||||
export const duplicateDevice1 = (device: TrezorDevice): AsyncAction => async (dispatch: Dispatch, getState: GetState): Promise<void> => {
|
||||
// dispatch({
|
||||
// type: CONNECT.TRY_TO_DUPLICATE,
|
||||
// device,
|
||||
// });
|
||||
|
||||
export const duplicateDeviceOld = (device: TrezorDevice): AsyncAction => async (dispatch: Dispatch, getState: GetState): Promise<void> => {
|
||||
const instance: number = getDuplicateInstanceNumber(getState().devices, device);
|
||||
const extended: Object = { instance };
|
||||
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> => {
|
||||
// dispatch({
|
||||
// type: CONNECT.TRY_TO_DUPLICATE,
|
||||
// device,
|
||||
// });
|
||||
|
||||
export const duplicateDevice = (device: TrezorDevice): AsyncAction => async (dispatch: Dispatch): Promise<void> => {
|
||||
dispatch({
|
||||
type: CONNECT.REQUEST_WALLET_TYPE,
|
||||
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: 'connect__forget' = 'connect__forget';
|
||||
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 REMEMBER: 'connect__remember' = 'connect__remember';
|
||||
|
||||
|
@ -271,6 +271,7 @@ const onChangeWalletType = (state: State, device: TrezorDevice, hidden: boolean)
|
||||
...d,
|
||||
state: null,
|
||||
useEmptyPassphrase: !hidden,
|
||||
ts: new Date().getTime(),
|
||||
} : d;
|
||||
});
|
||||
return otherDevices.concat(changedDevices);
|
||||
@ -296,6 +297,7 @@ export default function devices(state: State = initialState, action: Action): St
|
||||
case CONNECT.FORGET:
|
||||
return forgetDevice(state, action.device);
|
||||
case CONNECT.FORGET_SINGLE:
|
||||
case CONNECT.FORGET_SILENT:
|
||||
return forgetSingleDevice(state, action.device);
|
||||
|
||||
case DEVICE.CONNECT:
|
||||
|
Loading…
Reference in New Issue
Block a user