Skip to content

Commit 569b7c1

Browse files
committed
adds requested changes
1 parent e1d69f6 commit 569b7c1

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/components/Attachments/AttachmentView/DefaultAttachmentView/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
1212
type DefaultAttachmentViewProps = {
1313
/** The name of the file */
1414
fileName?: string;
15-
15+
1616
/** Should show the download icon */
1717
shouldShowDownloadIcon?: boolean;
1818

src/components/Attachments/AttachmentView/index.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ function AttachmentView({
9999
const styles = useThemeStyles();
100100
const StyleUtils = useStyleUtils();
101101
const [loadComplete, setLoadComplete] = useState(false);
102-
const [isPdfFailedToLoad, setIsPdfFailedToLoad] = useState(false);
102+
const [hasPDFFailedToLoad, setHasPDFFailedToLoad] = useState(false);
103103
const isVideo = (typeof source === 'string' && Str.isVideo(source)) || (file?.name && Str.isVideo(file.name));
104104

105105
useEffect(() => {
@@ -150,7 +150,9 @@ function AttachmentView({
150150

151151
// Check both source and file.name since PDFs dragged into the text field
152152
// will appear with a source that is a blob
153-
if (!isPdfFailedToLoad && ((typeof source === 'string' && Str.isPDF(source)) || (file && Str.isPDF(file.name ?? translate('attachmentView.unknownFilename'))))) {
153+
const isSourcePDF = typeof source === 'string' && Str.isPDF(source);
154+
const isFilePDF = file && Str.isPDF(file.name ?? translate('attachmentView.unknownFilename'));
155+
if (!hasPDFFailedToLoad && (isSourcePDF || isFilePDF)) {
154156
const encryptedSourceUrl = isAuthTokenRequired ? addEncryptedAuthTokenToURL(source as string) : (source as string);
155157

156158
const onPDFLoadComplete = (path: string) => {
@@ -164,7 +166,7 @@ function AttachmentView({
164166
};
165167

166168
const onPDFLoadError = () => {
167-
setIsPdfFailedToLoad(true);
169+
setHasPDFFailedToLoad(true);
168170
};
169171

170172
// We need the following View component on android native

0 commit comments

Comments
 (0)