diff options
Diffstat (limited to 'web/src/js/ducks/flows.js')
-rw-r--r-- | web/src/js/ducks/flows.js | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/web/src/js/ducks/flows.js b/web/src/js/ducks/flows.js index f96653a9..404db0d1 100644 --- a/web/src/js/ducks/flows.js +++ b/web/src/js/ducks/flows.js @@ -1,5 +1,6 @@ import { fetchApi } from '../utils' import reduceList, * as listActions from './utils/list' +import { selectRelative } from './flowView' import * as msgQueueActions from './msgQueue' import * as websocketActions from './websocket' @@ -210,5 +211,14 @@ export function updateFlow(item) { * @private */ export function removeFlow(id) { - return { type: REMOVE, id } + return (dispatch, getState) => { + let currentIndex = getState().flowView.indexOf[getState().flows.selected[0]] + let maxIndex = getState().flowView.data.length - 1 + let deleteLastEntry = maxIndex == 0 + if (deleteLastEntry) + dispatch(select()) + else + dispatch(selectRelative(currentIndex == maxIndex ? -1 : 1) ) + dispatch({ type: REMOVE, id }) + } } |