[MM-63643] Show image for video even if public link is disabled (#8824)

preview videos even if public link is disabled
This commit is contained in:
Guillermo Vayá 2025-05-05 17:45:37 +02:00 committed by GitHub
parent 738681a69a
commit 040fe0f9fc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 1 additions and 37 deletions

View file

@ -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 = (
<TouchableWithoutFeedback
disabled={isPressDisabled}

View file

@ -58,7 +58,6 @@ jest.mocked(File).mockImplementation((props) => (
<Text testID={`${props.file.id}-index`}>{props.index}</Text>
<Text testID={`${props.file.id}-isSingleImage`}>{String(props.isSingleImage)}</Text>
<Text testID={`${props.file.id}-nonVisibleImagesCount`}>{String(props.nonVisibleImagesCount)}</Text>
<Text testID={`${props.file.id}-publicLinkEnabled`}>{String(props.publicLinkEnabled)}</Text>
<Text testID={`${props.file.id}-wrapperWidth`}>{props.wrapperWidth}</Text>
<Text testID={`${props.file.id}-inViewPort`}>{String(props.inViewPort)}</Text>
<TouchableOpacity
@ -82,7 +81,6 @@ function getBaseProps(): ComponentProps<typeof Files> {
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(<Files {...baseProps}/>);
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(<Files {...baseProps}/>);
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(<Files {...baseProps}/>);
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(<Files {...baseProps}/>);
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', () => {

View file

@ -25,7 +25,6 @@ type FilesProps = {
isReplyPost: boolean;
postId?: string;
postProps?: Record<string, unknown>;
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}

View file

@ -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)}

View file

@ -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(() => {