import { SWIMLANE_TYPE } from '../../explorer_constants' ; import { getClearedSelectedAnomaliesState } from '../../explorer_utils' ; import { ExplorerState } from './state' ; interface SwimlanePoint { laneLabel : string ; time : number ; } export const checkSelectedCells = ( state ) => { const { filterActive , loading , selectedCells , viewBySwimlaneData , viewBySwimlaneDataLoading } = state ; if ( loading || viewBySwimlaneDataLoading ) { return { } ; } let clearSelection = false ; if ( selectedCells !== undefined && selectedCells !== null && selectedCells . type === SWIMLANE_TYPE . VIEW_BY && viewBySwimlaneData !== undefined && viewBySwimlaneData . points !== undefined && viewBySwimlaneData . points . length > 0 ) { clearSelection = filterActive === false && ! selectedCells . lanes . some ( ( lane ) => { return viewBySwimlaneData . points . some ( ( point ) => { return ( point . laneLabel === lane && point . time >= selectedCells . times [ 0 ] && point . time <= selectedCells . times [ 1 ] ) ; } ) ; } ) ; } if ( clearSelection === true ) { return { ... getClearedSelectedAnomaliesState ( ) , } ; } return { } ; } ;