use alertOnlyPDFSupported for document files (#9023) (#9029)

This commit is contained in:
Mattermost Build 2025-07-27 17:48:36 +03:00 committed by GitHub
parent 7996ab4fd3
commit 110f2049b6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -4,7 +4,7 @@
import {forwardRef, useImperativeHandle, type ReactNode, useCallback} from 'react';
import {useIntl} from 'react-intl';
import {alertDownloadDocumentDisabled} from '@utils/document';
import {alertDownloadDocumentDisabled, alertOnlyPDFSupported} from '@utils/document';
import {isPdf} from '@utils/file';
export type DocumentRef = {
@ -23,11 +23,16 @@ const Document = forwardRef<DocumentRef, DocumentProps>(({canDownloadFiles, chil
const intl = useIntl();
const handlePreviewPress = useCallback(async () => {
if (!canDownloadFiles || (enableSecureFilePreview && !isPdf(file))) {
if (!canDownloadFiles) {
alertDownloadDocumentDisabled(intl);
return;
}
if (enableSecureFilePreview && !isPdf(file)) {
alertOnlyPDFSupported(intl);
return;
}
downloadAndPreviewFile(file);
}, [canDownloadFiles, enableSecureFilePreview, downloadAndPreviewFile, file, intl]);