Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: PDF thumbnail reload when hovering on it #38031

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading