import _ from 'lodash' ; import { createSelector } from 'reselect' ; import { SerializedMessage } from 'libs/Message' ; import { SerializedNotification } from 'libs/Notification' ; import { isMessage , isNotification , isRejectedMessage } from 'store/ducks/logs' ; import { ApplicationState } from 'store/reducers' ; param state return const getLogsState = ( state ) => state . logs ; param state return const getLogsById = ( state ) => state . logs . byId ; param state return const getLogsAllIds = ( state ) => state . logs . allIds ; param state return export const getLogs = createSelector ( [ getLogsAllIds , getLogsById ] , ( allIds , byId ) => { let purgedCount = 0 ; let unhandledRejectedMessageCount = 0 ; const logs = _ . map ( allIds , ( id ) => { const log = byId [ id ] ; if ( isMessage ( log ) && log . purged ) { purgedCount += 1 ; } if ( isRejectedMessage ( log ) && ! log . handled ) { unhandledRejectedMessageCount += 1 ; } return log ; } ) ; return { logs , purgedCount , unhandledRejectedMessageCount } ; } ) ; param state return export const getLogsByIds = ( state , ids ) => { const logs = [ ] ; _ . forEach ( ids , ( id ) => { const log = _ . get ( state . logs . byId , id ) ; if ( ! _ . isNil ( log ) && ( isMessage ( log ) || isNotification ( log ) ) ) { logs . push ( log ) ; } } ) ; return logs ; } ; param state return export const getIsAutoScrollPaused = createSelector ( [ getLogsState ] , ( logs ) => logs . isAutoScrollPaused ) ; param state return export const getLastReadId = createSelector ( [ getLogsState ] , ( logs ) => logs . lastReadId ) ;