1
0
mirror of https://github.com/trezor/trezor-wallet synced 2024-11-15 12:59:09 +00:00
trezor-wallet/src/reducers/SelectedAccountReducer.js

61 lines
1.3 KiB
JavaScript
Raw Normal View History

2018-02-20 09:30:36 +00:00
/* @flow */
2018-08-14 13:11:52 +00:00
import * as ACCOUNT from 'actions/constants/account';
2018-02-20 09:30:36 +00:00
2019-03-04 12:33:02 +00:00
import type { Action, Account, Network, Token, Transaction, Discovery } from 'flowtype';
2018-04-16 21:19:50 +00:00
export type Loader = {
type: string,
title: string,
message?: string,
2019-03-04 12:33:02 +00:00
};
export type Notification = {
type: string,
title: string,
message?: string,
2019-03-04 12:33:02 +00:00
};
export type ExceptionPage = {
type: ?string,
title: ?string,
message: ?string,
shortcut: string,
2019-03-04 12:33:02 +00:00
};
2018-02-20 09:30:36 +00:00
export type State = {
location: string,
account: ?Account,
network: ?Network,
tokens: Array<Token>,
pending: Array<Transaction>,
2018-09-26 12:11:37 +00:00
discovery: ?Discovery,
loader: ?Loader,
notification: ?Notification,
exceptionPage: ?ExceptionPage,
shouldRender: boolean,
2018-02-20 09:30:36 +00:00
};
export const initialState: State = {
location: '/',
account: null,
network: null,
tokens: [],
pending: [],
2018-07-30 10:52:13 +00:00
discovery: null,
loader: null,
notification: null,
exceptionPage: null,
shouldRender: false,
};
2018-02-20 09:30:36 +00:00
export default (state: State = initialState, action: Action): State => {
2018-02-20 09:30:36 +00:00
switch (action.type) {
case ACCOUNT.DISPOSE:
return initialState;
2018-07-30 10:52:13 +00:00
case ACCOUNT.UPDATE_SELECTED_ACCOUNT:
return action.payload;
2018-02-20 09:30:36 +00:00
default:
return state;
}
2019-03-04 12:33:02 +00:00
};