Skip to content

Commit

Permalink
use getDisplayItems to get born digital pdfs to display
Browse files Browse the repository at this point in the history
  • Loading branch information
rcantin-w committed Jan 24, 2025
1 parent 83f343c commit 210d07d
Showing 1 changed file with 20 additions and 43 deletions.
63 changes: 20 additions & 43 deletions content/webapp/components/IIIFViewer/MainViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import useScrollVelocity from '@weco/content/hooks/useScrollVelocity';
import { SearchResults } from '@weco/content/services/iiif/types/search/v3';
import { TransformedCanvas } from '@weco/content/types/manifest';
import { TransformedAuthService } from '@weco/content/utils/iiif/v3';
import { getDisplayItems } from '@weco/content/utils/iiif/v3/canvas';

import { queryParamToArrayIndex } from '.';

Expand Down Expand Up @@ -262,10 +263,10 @@ const ItemRenderer = memo(({ style, index, data }: ItemRendererProps) => {
const [imageContainerRect, setImageContainerRect] = useState<
DOMRect | undefined
>();

const [overlayPositionData, setOverlayPositionData] = useState<
OverlayPositionData[]
>([]);

useEffect(() => {
// The search hit dimensions and coordinates are given relative to the full size image.
// The highlight overlays are positioned relative to the image container.
Expand Down Expand Up @@ -293,11 +294,8 @@ const ItemRenderer = memo(({ style, index, data }: ItemRendererProps) => {
}
}, [imageRect, imageContainerRect, currentCanvas, searchResults]);

const displayItems =
currentCanvas.painting.length > 0
? currentCanvas.painting
: currentCanvas.supplementing; // We fall back to supplementing for some of the pdfs

const displayItems = getDisplayItems(currentCanvas);
console.log({ displayItems: displayItems.length });
return (
<div style={style}>
{scrollVelocity === 3 ? (
Expand Down Expand Up @@ -335,43 +333,22 @@ const ItemRenderer = memo(({ style, index, data }: ItemRendererProps) => {
);
})}

{displayItems.map((item, i) => {
return (
<ItemWrapper key={i}>
{currentCanvas.painting.length > 0 &&
currentCanvas.painting.map((item, i) => {
return (
<IIIFItem
key={i}
placeholderId={placeholderId}
item={item}
canvas={currentCanvas}
i={index}
exclude={[]}
setImageRect={setImageRect}
setImageContainerRect={setImageContainerRect}
/>
);
})}
{/* Pdfs added to manifests before the DLCS changes, that took place in May 2023, are available from the supplementing property */}
{currentCanvas.painting.length === 0 &&
currentCanvas.supplementing.map((item, i) => {
return (
<IIIFItem
key={i}
placeholderId={placeholderId}
item={item}
canvas={currentCanvas}
i={index}
exclude={[]}
setImageRect={setImageRect}
setImageContainerRect={setImageContainerRect}
/>
);
})}
</ItemWrapper>
);
})}
{displayItems.length > 0 &&
displayItems.map(item => {
return (
<ItemWrapper key={item.id}>
<IIIFItem
placeholderId={placeholderId}
item={item}
canvas={currentCanvas}
i={index}
exclude={[]}
setImageRect={setImageRect}
setImageContainerRect={setImageContainerRect}
/>
</ItemWrapper>
);
})}
</>
)}
</div>
Expand Down

0 comments on commit 210d07d

Please sign in to comment.