import { createSelector } from 'reselect' import { IDomainObj } from './interfaces' import { get, indexOf, find } from 'lodash' export const settings = (state: any) => state.settings export const notificationSentMessage = (state: any): boolean => !!get(settings(state), 'notificationSentMessage') export const notificationVisitedSite = (state: any): boolean => !!get(settings(state), 'notificationVisitedSite') export const notificationClickedEmailLink = (state: any): boolean => !!get(settings(state), 'notificationClickedEmailLink') export const notificationOpenedEmail = (state: any): boolean => !!get(settings(state), 'notificationOpenedEmail') export const notificationMuteList = (state: any): string[] => get(settings(state), 'notificationMuteList', []) export const domainMuteList = (state: any): IDomainObj[] => get(settings(state), 'domainMuteList', []) export const hasUnfollowEntries = createSelector( [notificationMuteList, domainMuteList], (notificationMuteList, domainMuteList) => { return !!(notificationMuteList.length + domainMuteList.length) }) export const bccStatus = (state: any): boolean => !!get(settings(state), 'bccStatus', false) export const bccEmailAddress = (state: any): string => get(settings(state), 'bccEmailAddress', '') export const emailOnMuteList = (state: any, email: string): boolean => indexOf(notificationMuteList(state), email) >= 0 export const domainOnMuteList = (state: any, domain: string): boolean => !!find(domainMuteList(state), { domain }) export const inboxesToRunExtensionOn = (state: any): { [email: string]: boolean } => get(settings(state), 'inboxesToRunExtensionOn', {})