diff options
author | Jason <jason.daurus@gmail.com> | 2016-06-25 00:36:39 +0800 |
---|---|---|
committer | Jason <jason.daurus@gmail.com> | 2016-06-25 00:36:39 +0800 |
commit | 571c817f2176008c460c736580c0b35385808a2e (patch) | |
tree | 56c82a97c9eefdce37e05daebd35f669a93b554e /web/src/js/ducks/eventLog.js | |
parent | 5a1677c3879c53abcaddbbfa4894fa8a117a3143 (diff) | |
download | mitmproxy-571c817f2176008c460c736580c0b35385808a2e.tar.gz mitmproxy-571c817f2176008c460c736580c0b35385808a2e.tar.bz2 mitmproxy-571c817f2176008c460c736580c0b35385808a2e.zip |
[web] add msgQueue
Diffstat (limited to 'web/src/js/ducks/eventLog.js')
-rw-r--r-- | web/src/js/ducks/eventLog.js | 39 |
1 files changed, 6 insertions, 33 deletions
diff --git a/web/src/js/ducks/eventLog.js b/web/src/js/ducks/eventLog.js index 0c875689..50b24cd6 100644 --- a/web/src/js/ducks/eventLog.js +++ b/web/src/js/ducks/eventLog.js @@ -1,12 +1,12 @@ -import { fetchApi } from '../utils' import reduceList, * as listActions from './utils/list' import reduceView, * as viewActions from './utils/view' import * as websocketActions from './websocket' +import * as msgQueueActions from './msgQueue' -export const WS_MSG_TYPE = 'UPDATE_EVENTLOG' +export const MSG_TYPE = 'UPDATE_EVENTLOG' +export const DATA_URL = '/events' export const ADD = 'EVENTLOG_ADD' -export const REQUEST = 'EVENTLOG_REQUEST' export const RECEIVE = 'EVENTLOG_RECEIVE' export const TOGGLE_VISIBILITY = 'EVENTLOG_TOGGLE_VISIBILITY' export const TOGGLE_FILTER = 'EVENTLOG_TOGGLE_FILTER' @@ -51,12 +51,6 @@ export default function reduce(state = defaultState, action) { view: reduceView(state.view, viewActions.add(item, log => state.filters[log.level])), } - case REQUEST: - return { - ...state, - list: reduceList(state.list, listActions.request()), - } - case RECEIVE: const list = reduceList(state.list, listActions.receive(action.list)) return { @@ -120,33 +114,12 @@ export function handleWsMsg(msg) { * @public websocket */ export function fetchData() { - return dispatch => { - dispatch(request()) - - return fetchApi('/events') - .then(res => res.json()) - .then(json => dispatch(receive(json.data))) - .catch(error => dispatch(fetchError(error))) - } -} - -/** - * @private - */ -export function request() { - return { type: REQUEST } + return msgQueueActions.fetchData(MSG_TYPE) } /** - * @private + * @public msgQueue */ -export function receive(list) { +export function receiveData(list) { return { type: RECEIVE, list } } - -/** - * @private - */ -export function fetchError(error) { - return { type: FETCH_ERROR, error } -} |