Skip to content

Commit

Permalink
Merge pull request Expensify#38031 from eh2077/37852-fix-pdf-thumbnai…
Browse files Browse the repository at this point in the history
…l-reload-when-hovering-on-it

Fix: PDF thumbnail reload when hovering on it
  • Loading branch information
deetergp authored Mar 11, 2024
2 parents a1834ab + 381f1d8 commit 5469198
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/components/PDFThumbnail/index.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import useThemeStyles from '@hooks/useThemeStyles';
import addEncryptedAuthTokenToURL from '@libs/addEncryptedAuthTokenToURL';
import type PDFThumbnailProps from './types';

function PDFThumbnail({previewSourceURL, style, isAuthTokenRequired = false, enabled = true, onPassword = () => {}}: PDFThumbnailProps) {
function PDFThumbnail({previewSourceURL, style, isAuthTokenRequired = false, enabled = true, onPassword}: PDFThumbnailProps) {
const styles = useThemeStyles();
const sizeStyles = [styles.w100, styles.h100];

Expand All @@ -25,6 +25,9 @@ function PDFThumbnail({previewSourceURL, style, isAuthTokenRequired = false, ena
if (!('message' in error && typeof error.message === 'string' && error.message.match(/password/i))) {
return;
}
if (!onPassword) {
return;
}
onPassword();
}}
/>
Expand Down
6 changes: 2 additions & 4 deletions src/components/PDFThumbnail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if (!pdfjs.GlobalWorkerOptions.workerSrc) {
pdfjs.GlobalWorkerOptions.workerSrc = URL.createObjectURL(new Blob([pdfWorkerSource], {type: 'text/javascript'}));
}

function PDFThumbnail({previewSourceURL, style, isAuthTokenRequired = false, enabled = true, onPassword = () => {}}: PDFThumbnailProps) {
function PDFThumbnail({previewSourceURL, style, isAuthTokenRequired = false, enabled = true, onPassword}: PDFThumbnailProps) {
const styles = useThemeStyles();

const thumbnail = useMemo(
Expand All @@ -25,9 +25,7 @@ function PDFThumbnail({previewSourceURL, style, isAuthTokenRequired = false, ena
cMapPacked: true,
}}
externalLinkTarget="_blank"
onPassword={() => {
onPassword();
}}
onPassword={onPassword}
>
<View pointerEvents="none">
<Thumbnail pageIndex={0} />
Expand Down

0 comments on commit 5469198

Please sign in to comment.