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
|
|
|
|
2018-12-17 17:33:55 +00:00
|
|
|
export type Loader = {
|
|
|
|
type: string,
|
|
|
|
title: string,
|
|
|
|
message?: string,
|
2019-03-04 12:33:02 +00:00
|
|
|
};
|
2018-12-17 17:33:55 +00:00
|
|
|
|
|
|
|
export type Notification = {
|
|
|
|
type: string,
|
|
|
|
title: string,
|
|
|
|
message?: string,
|
2019-03-04 12:33:02 +00:00
|
|
|
};
|
2018-12-17 17:33:55 +00:00
|
|
|
|
|
|
|
export type ExceptionPage = {
|
|
|
|
type: ?string,
|
|
|
|
title: ?string,
|
|
|
|
message: ?string,
|
|
|
|
shortcut: string,
|
2019-03-04 12:33:02 +00:00
|
|
|
};
|
2018-12-17 17:33:55 +00:00
|
|
|
|
2018-02-20 09:30:36 +00:00
|
|
|
export type State = {
|
2018-12-17 17:33:55 +00:00
|
|
|
location: string,
|
|
|
|
account: ?Account,
|
|
|
|
network: ?Network,
|
2018-05-25 09:26:36 +00:00
|
|
|
tokens: Array<Token>,
|
2018-12-19 16:44:19 +00:00
|
|
|
pending: Array<Transaction>,
|
2018-09-26 12:11:37 +00:00
|
|
|
discovery: ?Discovery,
|
2018-12-17 17:33:55 +00:00
|
|
|
loader: ?Loader,
|
|
|
|
notification: ?Notification,
|
|
|
|
exceptionPage: ?ExceptionPage,
|
2018-09-26 17:35:36 +00:00
|
|
|
shouldRender: boolean,
|
2018-02-20 09:30:36 +00:00
|
|
|
};
|
|
|
|
|
2018-05-25 09:26:36 +00:00
|
|
|
export const initialState: State = {
|
|
|
|
location: '/',
|
|
|
|
account: null,
|
|
|
|
network: null,
|
|
|
|
tokens: [],
|
2018-05-25 09:49:15 +00:00
|
|
|
pending: [],
|
2018-07-30 10:52:13 +00:00
|
|
|
discovery: null,
|
2018-12-17 17:33:55 +00:00
|
|
|
loader: null,
|
|
|
|
notification: null,
|
|
|
|
exceptionPage: null,
|
2018-09-26 17:35:36 +00:00
|
|
|
shouldRender: false,
|
2018-05-25 09:26:36 +00:00
|
|
|
};
|
2018-02-20 09:30:36 +00:00
|
|
|
|
2018-05-25 09:26:36 +00:00
|
|
|
export default (state: State = initialState, action: Action): State => {
|
2018-02-20 09:30:36 +00:00
|
|
|
switch (action.type) {
|
2018-10-04 08:48:50 +00:00
|
|
|
case ACCOUNT.DISPOSE:
|
|
|
|
return initialState;
|
2018-07-30 10:52:13 +00:00
|
|
|
case ACCOUNT.UPDATE_SELECTED_ACCOUNT:
|
2018-05-25 09:26:36 +00:00
|
|
|
return action.payload;
|
2018-02-20 09:30:36 +00:00
|
|
|
default:
|
|
|
|
return state;
|
|
|
|
}
|
2019-03-04 12:33:02 +00:00
|
|
|
};
|