diff --git a/packages/react/src/views/AttachmentHandler/AttachmentMetadata.js b/packages/react/src/views/AttachmentHandler/AttachmentMetadata.js
index 5bd249ce5..390cab7b7 100644
--- a/packages/react/src/views/AttachmentHandler/AttachmentMetadata.js
+++ b/packages/react/src/views/AttachmentHandler/AttachmentMetadata.js
@@ -3,7 +3,14 @@ import { css } from '@emotion/react';
import { ActionButton, Box } from '@embeddedchat/ui-elements';
import { Markdown } from '../Markdown';
-const AttachmentMetadata = ({ attachment, url, variantStyles = {}, msg }) => {
+const AttachmentMetadata = ({
+ attachment,
+ url,
+ variantStyles = {},
+ msg,
+ onExpandCollapseClick,
+ isExpanded,
+}) => {
const handleDownload = async () => {
try {
const response = await fetch(url);
@@ -78,6 +85,16 @@ const AttachmentMetadata = ({ attachment, url, variantStyles = {}, msg }) => {
>
{attachment.title}
+
{
+ setIsExpanded((prevState) => !prevState);
+ };
+
return (
-
+ {isExpanded && (
+
+ )}
{attachment.attachments &&
attachment.attachments.map((nestedAttachment, index) => (
diff --git a/packages/react/src/views/AttachmentHandler/ImageAttachment.js b/packages/react/src/views/AttachmentHandler/ImageAttachment.js
index 04a2addc4..5f95829df 100644
--- a/packages/react/src/views/AttachmentHandler/ImageAttachment.js
+++ b/packages/react/src/views/AttachmentHandler/ImageAttachment.js
@@ -30,10 +30,14 @@ const ImageAttachment = ({
const { authorIcon, authorName } = author;
+ const [isExpanded, setIsExpanded] = useState(true);
+ const toggleExpanded = () => {
+ setIsExpanded((prevState) => !prevState);
+ };
+
return (
setShowGallery(true)}
css={[
css`
cursor: pointer;
@@ -77,16 +81,22 @@ const ImageAttachment = ({
url={host + (attachment.title_link || attachment.image_url)}
variantStyles={variantStyles}
msg={msg}
+ onExpandCollapseClick={toggleExpanded}
+ isExpanded={isExpanded}
/>
-
+ {isExpanded && (
+ setShowGallery(true)}>
+
+
+ )}
{attachment.attachments &&
attachment.attachments.map((nestedAttachment, index) => (
diff --git a/packages/react/src/views/AttachmentHandler/VideoAttachment.js b/packages/react/src/views/AttachmentHandler/VideoAttachment.js
index 0b364b1a2..4407481ee 100644
--- a/packages/react/src/views/AttachmentHandler/VideoAttachment.js
+++ b/packages/react/src/views/AttachmentHandler/VideoAttachment.js
@@ -1,4 +1,4 @@
-import React, { useContext } from 'react';
+import React, { useState, useContext } from 'react';
import PropTypes from 'prop-types';
import { css } from '@emotion/react';
import { Box, Avatar, useTheme } from '@embeddedchat/ui-elements';
@@ -31,6 +31,12 @@ const VideoAttachment = ({
return URL;
};
const { authorIcon, authorName } = author;
+
+ const [isExpanded, setIsExpanded] = useState(true);
+ const toggleExpanded = () => {
+ setIsExpanded((prevState) => !prevState);
+ };
+
return (
-
+ {isExpanded && (
+
+ )}
{attachment.attachments &&
attachment.attachments.map((nestedAttachment, index) => (
diff --git a/packages/react/src/views/Message/MessageToolbox.js b/packages/react/src/views/Message/MessageToolbox.js
index 066439433..34752872e 100644
--- a/packages/react/src/views/Message/MessageToolbox.js
+++ b/packages/react/src/views/Message/MessageToolbox.js
@@ -133,7 +133,7 @@ export const MessageToolbox = ({
id: 'pin',
onClick: () => handlePinMessage(message),
iconName: message.pinned ? 'pin-filled' : 'pin',
- visible: !isThreadMessage && isAllowedToPin,
+ visible: isAllowedToPin,
},
edit: {
label: 'Edit',