aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js/ducks/flows.js
diff options
context:
space:
mode:
authorJason <jason.daurus@gmail.com>2016-06-25 00:36:39 +0800
committerJason <jason.daurus@gmail.com>2016-06-25 00:36:39 +0800
commit571c817f2176008c460c736580c0b35385808a2e (patch)
tree56c82a97c9eefdce37e05daebd35f669a93b554e /web/src/js/ducks/flows.js
parent5a1677c3879c53abcaddbbfa4894fa8a117a3143 (diff)
downloadmitmproxy-571c817f2176008c460c736580c0b35385808a2e.tar.gz
mitmproxy-571c817f2176008c460c736580c0b35385808a2e.tar.bz2
mitmproxy-571c817f2176008c460c736580c0b35385808a2e.zip
[web] add msgQueue
Diffstat (limited to 'web/src/js/ducks/flows.js')
-rw-r--r--web/src/js/ducks/flows.js46
1 files changed, 10 insertions, 36 deletions
diff --git a/web/src/js/ducks/flows.js b/web/src/js/ducks/flows.js
index f732f536..e9ac38f6 100644
--- a/web/src/js/ducks/flows.js
+++ b/web/src/js/ducks/flows.js
@@ -1,14 +1,15 @@
import { fetchApi } from '../utils'
import reduceList, * as listActions from './utils/list'
import reduceViews, * as viewsActions from './views'
+import * as msgQueueActions from './msgQueue'
import * as websocketActions from './websocket'
-export const WS_MSG_TYPE = 'UPDATE_FLOWS'
+export const MSG_TYPE = 'UPDATE_FLOWS'
+export const DATA_URL = '/flows'
export const ADD = 'FLOWS_ADD'
export const UPDATE = 'FLOWS_UPDATE'
export const REMOVE = 'FLOWS_REMOVE'
-export const REQUEST = 'FLOWS_REQUEST'
export const RECEIVE = 'FLOWS_RECEIVE'
export const REQUEST_ACTION = 'FLOWS_REQUEST_ACTION'
export const UNKNOWN_CMD = 'FLOWS_UNKNOWN_CMD'
@@ -43,12 +44,6 @@ export default function reduce(state = defaultState, action) {
views: reduceViews(state.views, viewsActions.remove(action.item.id)),
}
- case REQUEST:
- return {
- ...state,
- list: reduceList(state.list, listActions.request()),
- }
-
case RECEIVE:
const list = reduceList(state.list, listActions.receive(action.list))
return {
@@ -177,14 +172,14 @@ export function handleWsMsg(msg) {
* @public websocket
*/
export function fetchData() {
- return dispatch => {
- dispatch(request())
+ return msgQueueActions.fetchData(MSG_TYPE)
+}
- return fetchApi('/flows')
- .then(res => res.json())
- .then(json => dispatch(receive(json.data)))
- .catch(error => dispatch(fetchError(error)))
- }
+/**
+ * @public msgQueue
+ */
+export function receiveData(list) {
+ return { type: RECEIVE, list }
}
/**
@@ -207,24 +202,3 @@ export function update(id, item) {
export function remove(id) {
return { type: REMOVE, id }
}
-
-/**
- * @private
- */
-export function request() {
- return { type: REQUEST }
-}
-
-/**
- * @private
- */
-export function receive(list) {
- return { type: RECEIVE, list }
-}
-
-/**
- * @private
- */
-export function fetchError(error) {
- return { type: FETCH_ERROR, error }
-}