fix
This commit is contained in:
@@ -3,7 +3,7 @@ import type { CSSProperties, JSX, MutableRefObject } from 'react';
|
||||
import {
|
||||
getAssetFromVersion,
|
||||
resolveDocumentAssetUrl,
|
||||
createAssetView,
|
||||
resolveAssetUrl,
|
||||
} from '../asset_manager';
|
||||
import type {
|
||||
DocumentLike as AssetManagerDocumentLike,
|
||||
@@ -101,13 +101,13 @@ const DocumentThumbnailImage = ({
|
||||
() => getAssetFromVersion(document?.current_version, 'thumbnail'),
|
||||
[document?.current_version],
|
||||
);
|
||||
const thumbnailView = useMemo(() => createAssetView(thumbnailAsset), [thumbnailAsset]);
|
||||
const primaryMetadata = thumbnailView.getPrimaryMetadata() || {};
|
||||
const assetWidth = Number(primaryMetadata?.width);
|
||||
const assetHeight = Number(primaryMetadata?.height);
|
||||
const thumbnailMetadata = (thumbnailAsset?.metadata as { width?: number; height?: number } | null) || null;
|
||||
const assetWidth = thumbnailMetadata?.width;
|
||||
const assetHeight = thumbnailMetadata?.height;
|
||||
|
||||
const dimensions = useMemo(() => {
|
||||
if (!Number.isFinite(assetWidth) || assetWidth <= 0 || !Number.isFinite(assetHeight) || assetHeight <= 0) {
|
||||
const hasDimensions = typeof assetWidth === 'number' && assetWidth > 0 && typeof assetHeight === 'number' && assetHeight > 0;
|
||||
if (!hasDimensions) {
|
||||
return { width: resolvedMaxSize, height: resolvedMaxSize };
|
||||
}
|
||||
const scale = Math.min(1, resolvedMaxSize / assetWidth, resolvedMaxSize / assetHeight);
|
||||
@@ -136,8 +136,8 @@ const DocumentThumbnailImage = ({
|
||||
if (getDocumentAsset) {
|
||||
options.getAsset = getDocumentAsset;
|
||||
}
|
||||
return resolveDocumentAssetUrl(document, 'thumbnail', options);
|
||||
}, [document, ensureAssetUrl, getDocumentAsset, isVisible]);
|
||||
return resolveDocumentAssetUrl(document, 'thumbnail', options) || resolveAssetUrl(thumbnailAsset);
|
||||
}, [document, ensureAssetUrl, getDocumentAsset, isVisible, thumbnailAsset]);
|
||||
|
||||
const pageCount = getPageCount(document);
|
||||
const showMultiPageBadge = Number.isFinite(pageCount) && pageCount > 1;
|
||||
@@ -147,11 +147,11 @@ const DocumentThumbnailImage = ({
|
||||
}
|
||||
|
||||
const aspectRatio = useMemo(() => {
|
||||
if (Number.isFinite(assetWidth) && Number.isFinite(assetHeight) && assetWidth > 0 && assetHeight > 0) {
|
||||
return assetWidth / assetHeight;
|
||||
if (dimensions.width > 0 && dimensions.height > 0) {
|
||||
return dimensions.width / dimensions.height;
|
||||
}
|
||||
return null;
|
||||
}, [assetWidth, assetHeight]);
|
||||
}, [dimensions.height, dimensions.width]);
|
||||
|
||||
useEffect(() => {
|
||||
const node = visibilityRef.current;
|
||||
|
||||
Reference in New Issue
Block a user