diff --git a/src/js/actions/WalletActions.js b/src/js/actions/WalletActions.js index 99bd2be3..c34a6d9c 100644 --- a/src/js/actions/WalletActions.js +++ b/src/js/actions/WalletActions.js @@ -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 => { diff --git a/src/js/actions/constants/wallet.js b/src/js/actions/constants/wallet.js index ef68a1d4..b183d00f 100644 --- a/src/js/actions/constants/wallet.js +++ b/src/js/actions/constants/wallet.js @@ -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'; \ No newline at end of file +export const ONLINE_STATUS: 'wallet__online_status' = 'wallet__online_status'; + +export const SET_SELECTED_DEVICE: 'wallet__set_selected_device' = 'wallet__set_selected_device'; \ No newline at end of file diff --git a/src/js/reducers/WalletReducer.js b/src/js/reducers/WalletReducer.js index b1d67f6c..cfe3d8d5 100644 --- a/src/js/reducers/WalletReducer.js +++ b/src/js/reducers/WalletReducer.js @@ -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; }