Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { IAttachment } from '../../../../definitions';
import { getMessageFromAttachment } from '../../utils';

const removeQuote = (file?: IAttachment) =>
file?.image_url || file?.audio_url || file?.video_url || (file?.actions?.length || 0) > 0;
file?.image_url || file?.audio_url || file?.video_url || (file?.actions?.length || 0) > 0 || file?.collapsed;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix filter: truthy check skips non-collapsed quotes. Use explicit boolean check.

file?.collapsed only includes true, excluding quotes with collapsed === false. Since rendering later checks typeof file.collapsed === 'boolean', align the filter to include both states.

-	file?.image_url || file?.audio_url || file?.video_url || (file?.actions?.length || 0) > 0 || file?.collapsed;
+	file?.image_url || file?.audio_url || file?.video_url || (file?.actions?.length || 0) > 0 || typeof file?.collapsed === 'boolean';

Optional (naming clarity):

  • Rename removeQuote to isRenderableAttachment.
  • Rename nonQuoteAttachments to renderableAttachments.
-const removeQuote = (file?: IAttachment) =>
-	file?.image_url || file?.audio_url || file?.video_url || (file?.actions?.length || 0) > 0 || typeof file?.collapsed === 'boolean';
+const isRenderableAttachment = (file?: IAttachment) =>
+	file?.image_url || file?.audio_url || file?.video_url || (file?.actions?.length || 0) > 0 || typeof file?.collapsed === 'boolean';

-const nonQuoteAttachments = attachments?.filter(removeQuote);
+const renderableAttachments = attachments?.filter(isRenderableAttachment);

And update subsequent uses accordingly.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
file?.image_url || file?.audio_url || file?.video_url || (file?.actions?.length || 0) > 0 || file?.collapsed;
file?.image_url || file?.audio_url || file?.video_url || (file?.actions?.length || 0) > 0 || typeof file?.collapsed === 'boolean';
🤖 Prompt for AI Agents
In app/containers/message/Components/Attachments/Attachments.tsx around line 16,
the filter uses file?.collapsed as a truthy check which excludes attachments
where collapsed === false (quotes that should still be considered); change the
filter to explicitly include boolean collapsed values (e.g. typeof
file.collapsed === 'boolean' or file.collapsed !== undefined) alongside the
existing image/audio/video/actions checks so both true and false collapsed are
kept, and optionally rename removeQuote to isRenderableAttachment and
nonQuoteAttachments to renderableAttachments and update all subsequent
references to match.


const Attachments: React.FC<IMessageAttachments> = React.memo(
({ attachments, timeFormat, showAttachment, style, getCustomEmoji, isReply, author }: IMessageAttachments) => {
Expand Down
30 changes: 30 additions & 0 deletions app/containers/message/Message.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1985,3 +1985,33 @@ export const LongNameUserLargeFont = () => (
/>
</>
);

const collapsedAttachments = {
collapsed: true,
title: 'Title collapsed',
fields: [
{
title: 'Field 1',
value: 'Value 1'
},
{
title: 'Field 2',
value: 'Value 2'
}
]
};
export const CollapsedAttachments = () => (
<>
<Message msg='Message' attachments={[collapsedAttachments]} />
{/* technically not CollapsibleQuote, but it's similar enough to write a story for */}
<Message msg='Message' attachments={[{ ...collapsedAttachments, collapsed: false }]} />
</>
);

export const CollapsedAttachmentsLargeFont = () => (
<>
<MessageLargeFont msg='Message' attachments={[collapsedAttachments]} />
{/* technically not CollapsibleQuote, but it's similar enough to write a story for */}
<MessageLargeFont msg='Message' attachments={[{ ...collapsedAttachments, collapsed: false }]} />
</>
);
Loading
Loading