mirror of
https://github.com/trezor/trezor-wallet
synced 2024-11-24 09:18:09 +00:00
WalletReducer: SET_SELECTED_DEVICE action
This commit is contained in:
parent
c7d7fa32d1
commit
ed23b859a8
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
import * as WALLET from './constants/wallet';
|
import * as WALLET from './constants/wallet';
|
||||||
|
|
||||||
import type { RouterLocationState, ThunkAction, Dispatch, GetState } from '~/flowtype';
|
import type { TrezorDevice, RouterLocationState, ThunkAction, Dispatch, GetState } from '~/flowtype';
|
||||||
|
|
||||||
export type WalletAction = {
|
export type WalletAction = {
|
||||||
type: typeof WALLET.SET_INITIAL_URL,
|
type: typeof WALLET.SET_INITIAL_URL,
|
||||||
@ -17,6 +17,9 @@ export type WalletAction = {
|
|||||||
} | {
|
} | {
|
||||||
type: typeof WALLET.ONLINE_STATUS,
|
type: typeof WALLET.ONLINE_STATUS,
|
||||||
online: boolean
|
online: boolean
|
||||||
|
} | {
|
||||||
|
type: typeof WALLET.SET_SELECTED_DEVICE,
|
||||||
|
device: ?TrezorDevice
|
||||||
}
|
}
|
||||||
|
|
||||||
export const init = (): ThunkAction => {
|
export const init = (): ThunkAction => {
|
||||||
|
@ -5,3 +5,5 @@ export const ON_BEFORE_UNLOAD: 'wallet__on_before_unload' = 'wallet__on_before_u
|
|||||||
export const TOGGLE_DEVICE_DROPDOWN: 'wallet__toggle_dropdown' = 'wallet__toggle_dropdown';
|
export const TOGGLE_DEVICE_DROPDOWN: 'wallet__toggle_dropdown' = 'wallet__toggle_dropdown';
|
||||||
export const SET_INITIAL_URL: 'wallet__set_initial_url' = 'wallet__set_initial_url';
|
export const SET_INITIAL_URL: 'wallet__set_initial_url' = 'wallet__set_initial_url';
|
||||||
export const ONLINE_STATUS: 'wallet__online_status' = 'wallet__online_status';
|
export const ONLINE_STATUS: 'wallet__online_status' = 'wallet__online_status';
|
||||||
|
|
||||||
|
export const SET_SELECTED_DEVICE: 'wallet__set_selected_device' = 'wallet__set_selected_device';
|
@ -18,6 +18,8 @@ type State = {
|
|||||||
initialParams: ?RouterLocationState;
|
initialParams: ?RouterLocationState;
|
||||||
initialPathname: ?string;
|
initialPathname: ?string;
|
||||||
disconnectRequest: ?TrezorDevice;
|
disconnectRequest: ?TrezorDevice;
|
||||||
|
|
||||||
|
selectedDevice: ?TrezorDevice;
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialState: State = {
|
const initialState: State = {
|
||||||
@ -26,7 +28,8 @@ const initialState: State = {
|
|||||||
dropdownOpened: false,
|
dropdownOpened: false,
|
||||||
initialParams: null,
|
initialParams: null,
|
||||||
initialPathname: null,
|
initialPathname: null,
|
||||||
disconnectRequest: null
|
disconnectRequest: null,
|
||||||
|
selectedDevice: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function wallet(state: State = initialState, action: Action): State {
|
export default function wallet(state: State = initialState, action: Action): State {
|
||||||
@ -79,6 +82,12 @@ export default function wallet(state: State = initialState, action: Action): Sta
|
|||||||
}
|
}
|
||||||
return state;
|
return state;
|
||||||
|
|
||||||
|
case WALLET.SET_SELECTED_DEVICE :
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
selectedDevice: action.device
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user