@@ -99,7 +99,7 @@ function AttachmentView({
99
99
const styles = useThemeStyles ( ) ;
100
100
const StyleUtils = useStyleUtils ( ) ;
101
101
const [ loadComplete , setLoadComplete ] = useState ( false ) ;
102
- const [ isPdfFailedToLoad , setIsPdfFailedToLoad ] = useState ( false ) ;
102
+ const [ hasPDFFailedToLoad , setHasPDFFailedToLoad ] = useState ( false ) ;
103
103
const isVideo = ( typeof source === 'string' && Str . isVideo ( source ) ) || ( file ?. name && Str . isVideo ( file . name ) ) ;
104
104
105
105
useEffect ( ( ) => {
@@ -150,7 +150,9 @@ function AttachmentView({
150
150
151
151
// Check both source and file.name since PDFs dragged into the text field
152
152
// 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 ) ) {
154
156
const encryptedSourceUrl = isAuthTokenRequired ? addEncryptedAuthTokenToURL ( source as string ) : ( source as string ) ;
155
157
156
158
const onPDFLoadComplete = ( path : string ) => {
@@ -164,7 +166,7 @@ function AttachmentView({
164
166
} ;
165
167
166
168
const onPDFLoadError = ( ) => {
167
- setIsPdfFailedToLoad ( true ) ;
169
+ setHasPDFFailedToLoad ( true ) ;
168
170
} ;
169
171
170
172
// We need the following View component on android native
0 commit comments