Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prevent showing link previews in AttachmentPreviewList #2398

Merged
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 @@ -23,6 +23,7 @@ import {
isLocalImageAttachment,
isLocalMediaAttachment,
isLocalVoiceRecordingAttachment,
isScrapedContent,
} from '../../Attachment';
import { useMessageInputContext } from '../../../context';

Expand Down Expand Up @@ -66,6 +67,7 @@ export const AttachmentPreviewList = <
data-testid='attachment-list-scroll-container'
>
{attachments.map((attachment) => {
if (isScrapedContent(attachment)) return null;
if (isLocalVoiceRecordingAttachment(attachment)) {
return (
<VoiceRecordingPreview
Expand Down
8 changes: 5 additions & 3 deletions src/components/MessageInput/MessageInputFlat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,11 @@ const MessageInputV2 = <
</div>
<div className='str-chat__message-textarea-container'>
{displayQuotedMessage && <QuotedMessagePreview quotedMessage={quotedMessage} />}
{isUploadEnabled && !!(numberOfUploads || attachments.length) && (
<AttachmentPreviewList />
)}
{isUploadEnabled &&
!!(
numberOfUploads ||
(attachments.length && attachments.length !== linkPreviews.size)
) && <AttachmentPreviewList />}

<div className='str-chat__message-textarea-with-emoji-picker'>
<ChatAutoComplete />
Expand Down
11 changes: 11 additions & 0 deletions src/components/MessageInput/__tests__/MessageInput.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,17 @@ function axeNoViolations(container) {
});
});

// todo: adjust tests once merged PR: feat: remove legacy style components #2394
it.todo('should show attachment previews if at least 1 file uploaded');
it.todo('should show attachment previews if at least one non-scraped attachments available');
it.todo('should not show scraped content in attachment previews');
it.todo(
'should not show attachment previews if no files uploaded and no attachments available',
);
it.todo(
'should not show attachment previews if no files uploaded and attachments available are only link previews',
);

// TODO: Check if pasting plaintext is not prevented -> tricky because recreating exact event is hard
// TODO: Remove image/file -> difficult because there is no easy selector and components are in react-file-utils
});
Expand Down
Loading