Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 23 additions & 12 deletions packages/react/src/views/AttachmentHandler/AudioAttachment.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ const AudioAttachment = ({
variantStyles,
msg,
}) => {
const { RCInstance } = useContext(RCContext);
const { RCInstance, ECOptions } = useContext(RCContext);
const hideAvatar = ECOptions?.showAvatar === false;
const { theme } = useTheme();
const getUserAvatarUrl = (icon) => {
const instanceHost = RCInstance.getHost();
Expand Down Expand Up @@ -56,12 +57,20 @@ const AudioAttachment = ({
variantStyles.textUserInfo,
]}
>
<Avatar
url={getUserAvatarUrl(authorIcon)}
alt="avatar"
size="1.2em"
/>
<Box>@{authorName}</Box>
{!hideAvatar && (
<Avatar
url={getUserAvatarUrl(authorIcon)}
alt="avatar"
size="1.2em"
/>
)}
<Box
css={css`
margin-bottom: ${hideAvatar ? '8px' : '0'};
`}
>
@{authorName}
</Box>
</Box>
</>
) : (
Expand Down Expand Up @@ -115,11 +124,13 @@ const AudioAttachment = ({
variantStyles.textUserInfo,
]}
>
<Avatar
url={getUserAvatarUrl(nestedAttachment.author_icon)}
alt="avatar"
size="1.2em"
/>
{!hideAvatar && (
<Avatar
url={getUserAvatarUrl(nestedAttachment?.author_icon)}
alt="avatar"
size="1.2em"
/>
)}
<Box>@{nestedAttachment.author_name}</Box>
</Box>
</>
Expand Down
37 changes: 25 additions & 12 deletions packages/react/src/views/AttachmentHandler/ImageAttachment.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ const ImageAttachment = ({
variantStyles = {},
msg,
}) => {
const { RCInstance } = useContext(RCContext);
const { RCInstance, ECOptions } = useContext(RCContext);
const hideAvatar = ECOptions?.showAvatar === false;
const [showGallery, setShowGallery] = useState(false);
const getUserAvatarUrl = (icon) => {
const instanceHost = RCInstance.getHost();
Expand Down Expand Up @@ -65,12 +66,22 @@ const ImageAttachment = ({
variantStyles.textUserInfo,
]}
>
<Avatar
url={getUserAvatarUrl(authorIcon)}
alt="avatar"
size="1.2em"
/>
<Box>@{authorName}</Box>
<>
{!hideAvatar && (
<Avatar
url={getUserAvatarUrl(authorIcon)}
alt="avatar"
size="1.2em"
/>
)}
</>
<Box
css={css`
margin-bottom: ${hideAvatar ? '8px' : '0'};
`}
>
@{authorName}
</Box>
</Box>
</>
) : (
Expand Down Expand Up @@ -131,11 +142,13 @@ const ImageAttachment = ({
variantStyles.textUserInfo,
]}
>
<Avatar
url={getUserAvatarUrl(nestedAttachment.author_icon)}
alt="avatar"
size="1.2em"
/>
{!hideAvatar && (
<Avatar
url={getUserAvatarUrl(nestedAttachment?.author_icon)}
alt="avatar"
size="1.2em"
/>
)}
<Box>@{nestedAttachment.author_name}</Box>
</Box>
</>
Expand Down
27 changes: 16 additions & 11 deletions packages/react/src/views/AttachmentHandler/TextAttachment.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import RCContext from '../../context/RCInstance';
import { Markdown } from '../Markdown';

const TextAttachment = ({ attachment, type, variantStyles = {} }) => {
const { RCInstance } = useContext(RCContext);
const { RCInstance, ECOptions } = useContext(RCContext);
const hideAvatar = ECOptions?.showAvatar === false;
const getUserAvatarUrl = (authorIcon) => {
const host = RCInstance.getHost();
const URL = `${host}${authorIcon}`;
Expand Down Expand Up @@ -48,11 +49,13 @@ const TextAttachment = ({ attachment, type, variantStyles = {} }) => {
>
{attachment?.author_name && (
<>
<Avatar
url={getUserAvatarUrl(attachment?.author_icon)}
alt="avatar"
size="1.2em"
/>
{!hideAvatar && (
<Avatar
url={getUserAvatarUrl(attachment?.author_icon)}
alt="avatar"
size="1.2em"
/>
)}
<Box>@{attachment?.author_name}</Box>
</>
)}
Expand Down Expand Up @@ -119,11 +122,13 @@ const TextAttachment = ({ attachment, type, variantStyles = {} }) => {
>
{nestedAttachment?.author_name && (
<>
<Avatar
url={getUserAvatarUrl(nestedAttachment?.author_icon)}
alt="avatar"
size="1.2em"
/>
{!hideAvatar && (
<Avatar
url={getUserAvatarUrl(nestedAttachment?.author_icon)}
alt="avatar"
size="1.2em"
/>
)}
<Box>@{nestedAttachment?.author_name}</Box>
</>
)}
Expand Down
35 changes: 23 additions & 12 deletions packages/react/src/views/AttachmentHandler/VideoAttachment.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ const VideoAttachment = ({
variantStyles = {},
msg,
}) => {
const { RCInstance } = useContext(RCContext);
const { RCInstance, ECOptions } = useContext(RCContext);
const hideAvatar = ECOptions?.showAvatar === false;
const { theme } = useTheme();
const getUserAvatarUrl = (icon) => {
const instanceHost = RCInstance.getHost();
Expand Down Expand Up @@ -66,12 +67,20 @@ const VideoAttachment = ({
variantStyles.textUserInfo,
]}
>
<Avatar
url={getUserAvatarUrl(authorIcon)}
alt="avatar"
size="1.2em"
/>
<Box>@{authorName}</Box>
{!hideAvatar && (
<Avatar
url={getUserAvatarUrl(authorIcon)}
alt="avatar"
size="1.2em"
/>
)}
<Box
css={css`
margin-bottom: ${hideAvatar ? '8px' : '0'};
`}
>
@{authorName}
</Box>
</Box>
</>
) : (
Expand Down Expand Up @@ -133,11 +142,13 @@ const VideoAttachment = ({
variantStyles.textUserInfo,
]}
>
<Avatar
url={getUserAvatarUrl(authorIcon)}
alt="avatar"
size="1.2em"
/>
{!hideAvatar && (
<Avatar
url={getUserAvatarUrl(nestedAttachment?.author_icon)}
alt="avatar"
size="1.2em"
/>
)}
<Box>@{authorName}</Box>
</Box>
</>
Expand Down
Loading