All files / app/codeCharta/state/store/dynamicSettings/focusedNodePath focusedNodePath.reducer.ts

100% Statements 9/9
100% Branches 2/2
100% Functions 4/4
100% Lines 9/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 1343x 43x 43x   43x 43x   1x 1x 3x 1x    
import { focusNode, setAllFocusedNodes, unfocusAllNodes, unfocusNode } from "./focusedNodePath.actions"
import { fileRoot } from "../../../../services/loadFile/fileRoot"
import { createReducer, on } from "@ngrx/store"
 
export const defaultFocusedNodePath: string[] = []
export const focusedNodePath = createReducer(
    defaultFocusedNodePath,
    on(setAllFocusedNodes, (_state, action) => [...action.value]),
    on(unfocusAllNodes, () => []),
    on(focusNode, (state, action) => (action.value === fileRoot.rootPath ? state : [action.value, ...state])),
    on(unfocusNode, state => state.slice(1))
)