Skip to content

Commit

Permalink
adds requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ishpaul777 committed May 15, 2024
1 parent e1d69f6 commit 569b7c1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
type DefaultAttachmentViewProps = {
/** The name of the file */
fileName?: string;

/** Should show the download icon */
shouldShowDownloadIcon?: boolean;

Expand Down
8 changes: 5 additions & 3 deletions src/components/Attachments/AttachmentView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ function AttachmentView({
const styles = useThemeStyles();
const StyleUtils = useStyleUtils();
const [loadComplete, setLoadComplete] = useState(false);
const [isPdfFailedToLoad, setIsPdfFailedToLoad] = useState(false);
const [hasPDFFailedToLoad, setHasPDFFailedToLoad] = useState(false);
const isVideo = (typeof source === 'string' && Str.isVideo(source)) || (file?.name && Str.isVideo(file.name));

useEffect(() => {
Expand Down Expand Up @@ -150,7 +150,9 @@ function AttachmentView({

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

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

const onPDFLoadError = () => {
setIsPdfFailedToLoad(true);
setHasPDFFailedToLoad(true);
};

// We need the following View component on android native
Expand Down

0 comments on commit 569b7c1

Please sign in to comment.