// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. import React from 'react'; import {fetchUserByIdBatched} from '@actions/remote/user'; import CompassIcon from '@components/compass_icon'; import ProfilePicture from '@components/profile_picture'; import {useServerUrl} from '@context/server'; import {useTheme} from '@context/theme'; import useDidMount from '@hooks/did_mount'; import {changeOpacity, makeStyleSheetFromTheme} from '@utils/theme'; import type UserModel from '@typings/database/models/servers/user'; import type {StyleProp, TextStyle, ViewStyle} from 'react-native'; type Props = { authorId: string; author?: UserModel; isOnCenterBg?: boolean; style: StyleProp>; size: number; } const getStyleSheet = makeStyleSheetFromTheme((theme: Theme) => ({ status: { backgroundColor: theme.sidebarBg, borderWidth: 0, }, statusOnCenterBg: { backgroundColor: theme.centerChannelBg, }, icon: { color: changeOpacity(theme.sidebarText, 0.4), left: 1, }, iconOnCenterBg: { color: changeOpacity(theme.centerChannelColor, 0.72), }, })); const DmAvatar = ({ authorId, author, isOnCenterBg, style, size, }: Props) => { const theme = useTheme(); const serverUrl = useServerUrl(); const styles = getStyleSheet(theme); useDidMount(() => { if (authorId && !author) { fetchUserByIdBatched(serverUrl, authorId); } }); if (author?.deleteAt) { return ( ); } return ( ); }; export default DmAvatar;