import React from 'react'; import { shallowEqual, useSelector } from 'react-redux'; import { IApplicationState } from '../../definitions'; import { getUserSelector } from '../../selectors/login'; import Avatar from './Avatar'; import { IAvatar } from './interfaces'; import { useAvatarETag } from './useAvatarETag'; const AvatarContainer = ({ style, text = '', avatar, emoji, size, borderRadius, type, children, onPress, getCustomEmoji, isStatic, rid }: IAvatar): React.ReactElement => { const server = useSelector((state: IApplicationState) => state.share.server.server || state.server.server); const serverVersion = useSelector((state: IApplicationState) => state.share.server.version || state.server.version); const { id, token, username } = useSelector( (state: IApplicationState) => ({ id: getUserSelector(state).id, token: getUserSelector(state).token, username: getUserSelector(state).username }), shallowEqual ); const { avatarExternalProviderUrl, roomAvatarExternalProviderUrl, cdnPrefix } = useSelector((state: IApplicationState) => ({ avatarExternalProviderUrl: state.settings.Accounts_AvatarExternalProviderUrl as string, roomAvatarExternalProviderUrl: state.settings.Accounts_RoomAvatarExternalProviderUrl as string, cdnPrefix: state.settings.CDN_PREFIX as string })); const blockUnauthenticatedAccess = useSelector( (state: IApplicationState) => (state.share.settings?.Accounts_AvatarBlockUnauthenticatedAccess as boolean) ?? state.settings.Accounts_AvatarBlockUnauthenticatedAccess ?? true ); const { avatarETag } = useAvatarETag({ username, text, type, rid, id }); return ( ); }; export default AvatarContainer;