aboutsummaryrefslogtreecommitdiffstats
path: root/web/src/js/ducks/eventLog.js
diff options
context:
space:
mode:
Diffstat (limited to 'web/src/js/ducks/eventLog.js')
-rw-r--r--web/src/js/ducks/eventLog.js39
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 }
-}