function reducer()

in packages/dag-history-component/src/state/reducers/dragDrop.ts [23:52]


function reducer(
	state: State = INITIAL_STATE,
	action: ReduxActions.Action<any>,
	config: Configuration<any>,
) {
	let result = state
	if (action.type === BOOKMARK_DRAG_START) {
		result = {
			...state,
			sourceIndex: action.payload.index,
			sourceKey: action.payload.key,
		}
	} else if (action.type === BOOKMARK_DRAG_HOVER) {
		const hoverIndex = action.payload.index
		result = {
			...state,
			hoverIndex,
		}
	} else if (action.type === BOOKMARK_DRAG_DROP) {
		result = INITIAL_STATE
	} else if (action.type === BOOKMARK_DRAG_CANCEL) {
		result = INITIAL_STATE
	} else if (
		action.type.indexOf('DAG_HISTORY_') !== 0 &&
		config.actionFilter(action.type)
	) {
		result = INITIAL_STATE
	}
	return result
}