use alertOnlyPDFSupported for document files (#9023)
This commit is contained in:
parent
b2cec1c7a1
commit
85d6915bad
1 changed files with 7 additions and 2 deletions
|
|
@ -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]);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue