1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-12-25 16:38:08 +00:00

WalletReducer: SET_SELECTED_DEVICE action

This commit is contained in:
Szymon Lesisz 2018-05-22 19:41:10 +02:00
parent c7d7fa32d1
commit ed23b859a8
3 changed files with 17 additions and 3 deletions

View File

@ -3,7 +3,7 @@
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 = {
type: typeof WALLET.SET_INITIAL_URL,
@ -17,6 +17,9 @@ export type WalletAction = {
} | {
type: typeof WALLET.ONLINE_STATUS,
online: boolean
} | {
type: typeof WALLET.SET_SELECTED_DEVICE,
device: ?TrezorDevice
}
export const init = (): ThunkAction => {

View File

@ -4,4 +4,6 @@
export const ON_BEFORE_UNLOAD: 'wallet__on_before_unload' = 'wallet__on_before_unload';
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 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';

View File

@ -18,6 +18,8 @@ type State = {
initialParams: ?RouterLocationState;
initialPathname: ?string;
disconnectRequest: ?TrezorDevice;
selectedDevice: ?TrezorDevice;
}
const initialState: State = {
@ -26,7 +28,8 @@ const initialState: State = {
dropdownOpened: false,
initialParams: null,
initialPathname: null,
disconnectRequest: null
disconnectRequest: null,
selectedDevice: null,
};
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;
case WALLET.SET_SELECTED_DEVICE :
return {
...state,
selectedDevice: action.device
}
default:
return state;
}