From 040fe0f9fce30f7abfe8ee73ff03bcbc07e5652b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillermo=20Vay=C3=A1?= Date: Mon, 5 May 2025 17:45:37 +0200 Subject: [PATCH] [MM-63643] Show image for video even if public link is disabled (#8824) preview videos even if public link is disabled --- app/components/files/file.tsx | 4 +-- app/components/files/files.test.tsx | 26 -------------------- app/components/files/files.tsx | 3 --- app/components/files_search/file_result.tsx | 3 --- app/components/files_search/file_results.tsx | 2 -- 5 files changed, 1 insertion(+), 37 deletions(-) diff --git a/app/components/files/file.tsx b/app/components/files/file.tsx index a9800f299..3f6aa7843 100644 --- a/app/components/files/file.tsx +++ b/app/components/files/file.tsx @@ -31,7 +31,6 @@ type FileProps = { isSingleImage?: boolean; nonVisibleImagesCount: number; onPress: (index: number) => void; - publicLinkEnabled: boolean; channelName?: string; onOptionsPress?: (fileInfo: FileInfo) => void; optionSelected?: boolean; @@ -84,7 +83,6 @@ const File = ({ onOptionsPress, onPress, optionSelected, - publicLinkEnabled, showDate = false, updateFileForGallery, wrapperWidth = 300, @@ -148,7 +146,7 @@ const File = ({ ); let fileComponent; - if (isVideo(file) && publicLinkEnabled) { + if (isVideo(file)) { const renderVideoFile = ( ( {props.index} {String(props.isSingleImage)} {String(props.nonVisibleImagesCount)} - {String(props.publicLinkEnabled)} {props.wrapperWidth} {String(props.inViewPort)} { location: 'test-location', postId: 'test-post-id', postProps: {}, - publicLinkEnabled: true, }; } @@ -172,40 +170,16 @@ describe('Files', () => { const baseProps = getBaseProps(); baseProps.filesInfo = filesInfo; baseProps.canDownloadFiles = false; - baseProps.publicLinkEnabled = false; const {getByTestId, rerender} = render(); expect(getByTestId('1-canDownloadFiles')).toHaveTextContent('false'); - expect(getByTestId('1-publicLinkEnabled')).toHaveTextContent('false'); expect(getByTestId('2-canDownloadFiles')).toHaveTextContent('false'); - expect(getByTestId('2-publicLinkEnabled')).toHaveTextContent('false'); baseProps.canDownloadFiles = true; - baseProps.publicLinkEnabled = true; rerender(); expect(getByTestId('1-canDownloadFiles')).toHaveTextContent('true'); - expect(getByTestId('1-publicLinkEnabled')).toHaveTextContent('true'); expect(getByTestId('2-canDownloadFiles')).toHaveTextContent('true'); - expect(getByTestId('2-publicLinkEnabled')).toHaveTextContent('true'); - - baseProps.canDownloadFiles = true; - baseProps.publicLinkEnabled = false; - - rerender(); - expect(getByTestId('1-canDownloadFiles')).toHaveTextContent('true'); - expect(getByTestId('1-publicLinkEnabled')).toHaveTextContent('false'); - expect(getByTestId('2-canDownloadFiles')).toHaveTextContent('true'); - expect(getByTestId('2-publicLinkEnabled')).toHaveTextContent('false'); - - baseProps.canDownloadFiles = false; - baseProps.publicLinkEnabled = true; - - rerender(); - expect(getByTestId('1-canDownloadFiles')).toHaveTextContent('false'); - expect(getByTestId('1-publicLinkEnabled')).toHaveTextContent('true'); - expect(getByTestId('2-canDownloadFiles')).toHaveTextContent('false'); - expect(getByTestId('2-publicLinkEnabled')).toHaveTextContent('true'); }); it('should set layoutWidth if provided', () => { diff --git a/app/components/files/files.tsx b/app/components/files/files.tsx index a5a5e9b6c..64f6a8353 100644 --- a/app/components/files/files.tsx +++ b/app/components/files/files.tsx @@ -25,7 +25,6 @@ type FilesProps = { isReplyPost: boolean; postId?: string; postProps?: Record; - publicLinkEnabled: boolean; } const MAX_VISIBLE_ROW_IMAGES = 4; @@ -58,7 +57,6 @@ const Files = ({ location, postId, postProps, - publicLinkEnabled, }: FilesProps) => { const galleryIdentifier = `${postId}-fileAttachments-${location}`; const [inViewPort, setInViewPort] = useState(false); @@ -113,7 +111,6 @@ const Files = ({ onPress={handlePreviewPress} isSingleImage={isSingleImage} nonVisibleImagesCount={nonVisibleImagesCount} - publicLinkEnabled={publicLinkEnabled} updateFileForGallery={updateFileForGallery} wrapperWidth={layoutWidth || wrapperWidth} inViewPort={inViewPort} diff --git a/app/components/files_search/file_result.tsx b/app/components/files_search/file_result.tsx index 38fb3285d..7e8cc5628 100644 --- a/app/components/files_search/file_result.tsx +++ b/app/components/files_search/file_result.tsx @@ -29,7 +29,6 @@ type Props = { numOptions: number; onOptionsPress: (finfo: FileInfo) => void; onPress: (idx: number) => void; - publicLinkEnabled: boolean; setAction: (action: GalleryAction) => void; updateFileForGallery: (idx: number, file: FileInfo) => void; } @@ -44,7 +43,6 @@ const FileResult = ({ numOptions, onOptionsPress, onPress, - publicLinkEnabled, setAction, updateFileForGallery, }: Props) => { @@ -92,7 +90,6 @@ const FileResult = ({ onOptionsPress={handleOptionsPress} onPress={onPress} optionSelected={isTablet && showOptions} - publicLinkEnabled={publicLinkEnabled} showDate={true} updateFileForGallery={updateFileForGallery} wrapperWidth={(getViewPortWidth(isReplyPost, isTablet) - 6)} diff --git a/app/components/files_search/file_results.tsx b/app/components/files_search/file_results.tsx index 0aa23b87c..887758c2a 100644 --- a/app/components/files_search/file_results.tsx +++ b/app/components/files_search/file_results.tsx @@ -122,7 +122,6 @@ const FileResults = ({ numOptions={numOptions} onOptionsPress={onOptionsPress} onPress={onPreviewPress} - publicLinkEnabled={publicLinkEnabled} setAction={setAction} updateFileForGallery={updateFileForGallery} /> @@ -135,7 +134,6 @@ const FileResults = ({ onPreviewPress, onOptionsPress, numOptions, - publicLinkEnabled, ]); const noResults = useMemo(() => {