import { createSelector } from 'reselect' ; import without from 'lodash/without' ; import { getConfig } from '../config' ; import type { State } from '../types' ; import type { Config } from '../config/types' ; import type { AlertId , AlertsState } from './types' ; const getIgnoredAlertsFromConfig = createSelector ( getConfig , ( config ) => ( config ?. alerts . ignored as AlertId [ ] ) ?? null ) ; export const getActiveAlerts = createSelector ( state => state . alerts , getIgnoredAlertsFromConfig , ( alerts , ignoredAlerts ) : AlertId [ ] => { return ignoredAlerts !== null ? without ( alerts . active , ... alerts . ignored , ... ignoredAlerts ) : [ ] ; } ) ; export const getAlertIsPermanentlyIgnored = ( state , alertId ) : boolean | null => { const permaIgnoreList = getIgnoredAlertsFromConfig ( state ) ; return permaIgnoreList ? permaIgnoreList . includes ( alertId ) : null ; } ;