1 import { useRef } from 'react';
3 import { useTheme } from '@proton/components/containers/themes/ThemeProvider';
4 import useAuthentication from '@proton/components/hooks/useAuthentication';
5 import useConfig from '@proton/components/hooks/useConfig';
7 import { getImageSize, getSenderImageUrl } from '../helpers/senderImage';
10 * Return the sender image URL for a given email address
11 * @param emailAddress email address to get the sender image for
13 * @returns the sender image URL
15 const useSenderImage = (emailAddress: string, bimiSelector?: string) => {
16 const theme = useTheme();
17 const imageSizeRef = useRef(getImageSize());
18 const mode = theme.information.dark ? 'dark' : 'light';
19 const { UID } = useAuthentication();
20 const { API_URL } = useConfig();
21 return emailAddress ? getSenderImageUrl(API_URL, UID, emailAddress, imageSizeRef.current, bimiSelector, mode) : '';
24 export default useSenderImage;