diff options
Diffstat (limited to 'web/src/js/ducks')
-rw-r--r-- | web/src/js/ducks/flows.js | 6 | ||||
-rw-r--r-- | web/src/js/ducks/utils/store.js | 16 |
2 files changed, 19 insertions, 3 deletions
diff --git a/web/src/js/ducks/flows.js b/web/src/js/ducks/flows.js index 3375e4bd..d3717533 100644 --- a/web/src/js/ducks/flows.js +++ b/web/src/js/ducks/flows.js @@ -1,6 +1,5 @@ import { fetchApi } from "../utils" -import reduceStore from "./utils/store" -import * as storeActions from "./utils/store" +import reduceStore, * as storeActions from "./utils/store" import Filt from "../filt/filt" import { RequestUtils } from "../flow/utils" @@ -30,7 +29,8 @@ export default function reduce(state = defaultState, action) { case UPDATE: case REMOVE: case RECEIVE: - // FIXME: Implement select switch for remove + // FIXME: Update state.selected on REMOVE: + // The selected flow may have been removed, we need to select the next one in the view. let storeAction = storeActions[action.cmd]( action.data, makeFilter(state.filter), diff --git a/web/src/js/ducks/utils/store.js b/web/src/js/ducks/utils/store.js index 3252d697..9ea4f02e 100644 --- a/web/src/js/ducks/utils/store.js +++ b/web/src/js/ducks/utils/store.js @@ -13,6 +13,22 @@ const defaultState = { viewIndex: {}, } +/** + * The store reducer can be used as a mixin to another reducer that always returns a + * new { byId, list, listIndex, view, viewIndex } object. The reducer using the store + * usually has to map its action to the matching store action and then call the mixin with that. + * + * Example Usage: + * + * import reduceStore, * as storeActions from "./utils/store" + * + * case EVENTLOG_ADD: + * return { + * ...state, + * ...reduceStore(state, storeActions.add(action.data)) + * } + * + */ export default function reduce(state = defaultState, action) { let { byId, list, listIndex, view, viewIndex } = state |