From f0cd7546fd4c9ded78f681fb3c31886721e683b9 Mon Sep 17 00:00:00 2001 From: Piyush Bhatt <2023kuec2027@iiitkota.ac.in> Date: Fri, 3 Jan 2025 22:24:07 +0530 Subject: [PATCH 1/2] hideAvatar --- .../AttachmentHandler/AudioAttachment.js | 27 ++++++++++------- .../AttachmentHandler/ImageAttachment.js | 29 ++++++++++++------- .../views/AttachmentHandler/TextAttachment.js | 27 ++++++++++------- .../AttachmentHandler/VideoAttachment.js | 27 ++++++++++------- 4 files changed, 66 insertions(+), 44 deletions(-) diff --git a/packages/react/src/views/AttachmentHandler/AudioAttachment.js b/packages/react/src/views/AttachmentHandler/AudioAttachment.js index b88d0a41da..3114e3238b 100644 --- a/packages/react/src/views/AttachmentHandler/AudioAttachment.js +++ b/packages/react/src/views/AttachmentHandler/AudioAttachment.js @@ -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(); @@ -50,11 +51,13 @@ const AudioAttachment = ({ variantStyles.textUserInfo, ]} > - + {!hideAvatar && ( + + )} @{authorName} @@ -101,11 +104,13 @@ const AudioAttachment = ({ variantStyles.textUserInfo, ]} > - + {!hideAvatar && ( + + )} @{nestedAttachment.author_name} diff --git a/packages/react/src/views/AttachmentHandler/ImageAttachment.js b/packages/react/src/views/AttachmentHandler/ImageAttachment.js index 04a2addc49..2628638e19 100644 --- a/packages/react/src/views/AttachmentHandler/ImageAttachment.js +++ b/packages/react/src/views/AttachmentHandler/ImageAttachment.js @@ -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(); @@ -61,11 +62,15 @@ const ImageAttachment = ({ variantStyles.textUserInfo, ]} > - + <> + {!hideAvatar && ( + + )} + @{authorName} @@ -121,11 +126,13 @@ const ImageAttachment = ({ variantStyles.textUserInfo, ]} > - + {!hideAvatar && ( + + )} @{nestedAttachment.author_name} diff --git a/packages/react/src/views/AttachmentHandler/TextAttachment.js b/packages/react/src/views/AttachmentHandler/TextAttachment.js index bc79b8c5c4..00e4182463 100644 --- a/packages/react/src/views/AttachmentHandler/TextAttachment.js +++ b/packages/react/src/views/AttachmentHandler/TextAttachment.js @@ -5,7 +5,8 @@ import { Box, Avatar, useTheme } from '@embeddedchat/ui-elements'; import RCContext from '../../context/RCInstance'; 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}`; @@ -47,11 +48,13 @@ const TextAttachment = ({ attachment, type, variantStyles = {} }) => { > {attachment?.author_name && ( <> - + {!hideAvatar && ( + + )} @{attachment?.author_name} )} @@ -110,11 +113,13 @@ const TextAttachment = ({ attachment, type, variantStyles = {} }) => { > {nestedAttachment?.author_name && ( <> - + {!hideAvatar && ( + + )} @{nestedAttachment?.author_name} )} diff --git a/packages/react/src/views/AttachmentHandler/VideoAttachment.js b/packages/react/src/views/AttachmentHandler/VideoAttachment.js index 0b364b1a2d..2870e0b8eb 100644 --- a/packages/react/src/views/AttachmentHandler/VideoAttachment.js +++ b/packages/react/src/views/AttachmentHandler/VideoAttachment.js @@ -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(); @@ -60,11 +61,13 @@ const VideoAttachment = ({ variantStyles.textUserInfo, ]} > - + {!hideAvatar && ( + + )} @{authorName} @@ -122,11 +125,13 @@ const VideoAttachment = ({ variantStyles.textUserInfo, ]} > - + {!hideAvatar && ( + + )} @{authorName} From 161cc82ef6be0cd8ae933f245be786559ed86c28 Mon Sep 17 00:00:00 2001 From: Piyush Bhatt <2023kuec2027@iiitkota.ac.in> Date: Sat, 11 Jan 2025 23:06:10 +0530 Subject: [PATCH 2/2] fix_css --- .../react/src/views/AttachmentHandler/AudioAttachment.js | 8 +++++++- .../react/src/views/AttachmentHandler/ImageAttachment.js | 8 +++++++- .../react/src/views/AttachmentHandler/VideoAttachment.js | 8 +++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/packages/react/src/views/AttachmentHandler/AudioAttachment.js b/packages/react/src/views/AttachmentHandler/AudioAttachment.js index 3114e3238b..464430925a 100644 --- a/packages/react/src/views/AttachmentHandler/AudioAttachment.js +++ b/packages/react/src/views/AttachmentHandler/AudioAttachment.js @@ -58,7 +58,13 @@ const AudioAttachment = ({ size="1.2em" /> )} - @{authorName} + + @{authorName} + ) : ( diff --git a/packages/react/src/views/AttachmentHandler/ImageAttachment.js b/packages/react/src/views/AttachmentHandler/ImageAttachment.js index 2628638e19..d527a7637f 100644 --- a/packages/react/src/views/AttachmentHandler/ImageAttachment.js +++ b/packages/react/src/views/AttachmentHandler/ImageAttachment.js @@ -71,7 +71,13 @@ const ImageAttachment = ({ /> )} - @{authorName} + + @{authorName} + ) : ( diff --git a/packages/react/src/views/AttachmentHandler/VideoAttachment.js b/packages/react/src/views/AttachmentHandler/VideoAttachment.js index 2870e0b8eb..b34ed5e8e5 100644 --- a/packages/react/src/views/AttachmentHandler/VideoAttachment.js +++ b/packages/react/src/views/AttachmentHandler/VideoAttachment.js @@ -68,7 +68,13 @@ const VideoAttachment = ({ size="1.2em" /> )} - @{authorName} + + @{authorName} + ) : (