import { toMap } from '@proton/shared/lib/helpers/object' ; import { Folder } from '@proton/shared/lib/interfaces/Folder' ; import { useFolders } from './useCategories' ; import { useMailSettings } from './useMailSettings' ; const useFolderColor = ( folder ) => { const [ folders ] = useFolders ( ) ; const [ mailSettings ] = useMailSettings ( ) ; if ( ! mailSettings ?. EnableFolderColor ) { return undefined ; } if ( ! mailSettings ?. InheritParentFolderColor ) { return folder . Color ; } const folderMap = toMap ( folders ) ; const getParentFolderColor = ( { ParentID , Color } ) : string | undefined => { if ( ! ParentID ) { return Color ; } const folder = folderMap [ ParentID ] ; if ( folder ) { return getParentFolderColor ( folder ) ; } return undefined ; } ; return getParentFolderColor ( folder ) ; } ; export default useFolderColor ;