Skip to content
Open

eh? #442

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
14 changes: 12 additions & 2 deletions app/items/[uuid]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,27 @@ export default async function ItemViewer({ params, searchParams }: ItemProps) {
]);
if (!itemData) {
const capture = await CollectionsApi.getCaptureMetadata(params.uuid);
console.log("rendering with a capture uuid:");
redirect(
`/items/${capture.itemUuid}?canvasIndex=${capture.orderInSequence - 1}`
);
}

const item = new ItemModel(params.uuid, manifest, itemData.captures);
// TO DO: IDK we might want to factor in captures here? but this is at least a start

if (!searchParams.canvasIndex && itemData) {
redirect(`/items/${params.uuid}?canvasIndex=0`);
}

console.log("rendering with an item uuid:");

const item = new ItemModel(params.uuid, manifest, itemData.captures);
// only allow canvasIndex to be in the range of 0...item.imageIds.length (number of canvases)
const imageIDs = item.imageIDs || [];
const maxIndex = imageIDs.length - 1;
const rawIndex = searchParams.canvasIndex || 0;
const rawIndex = searchParams.canvasIndex;

// const rawIndex = searchParams.canvasIndex || 0;
const clampedCanvasIndex = Math.max(0, Math.min(rawIndex, maxIndex));
const breadcrumbData = formatItemBreadcrumbs(item);
return (
Expand Down