import { FolderWithSubFolders } from '@proton/shared/lib/interfaces/Folder' ; import { UnreadCounts } from '../components/sidebar/MailSidebarList' ; export const getUnreadCount = ( counterMap , folder ) : number => { if ( folder . Expanded ) { return counterMap [ folder . ID ] || 0 ; } return ( folder ?. subfolders || [ ] ) . reduce ( ( acc , fold ) => acc + getUnreadCount ( counterMap , { ... fold , Expanded : 0 } ) , counterMap [ folder . ID ] || 0 ) ; } ;