Skip to content
Snippets Groups Projects
Unverified Commit 63b6edb4 authored by Jack Reed's avatar Jack Reed Committed by GitHub
Browse files

Merge pull request #1941 from ProjectMirador/1888-app-crashes-while-loading-canvas-thumbnails

1888 app crashes while loading canvas thumbnails
parents 9e1945b0 3a48df55
No related branches found
No related tags found
No related merge requests found
......@@ -82,6 +82,7 @@ export class ThumbnailNavigation extends Component {
>
<CanvasThumbnail
imageUrl={manifestoCanvas.thumbnail(null, height)}
isValid={manifestoCanvas.hasValidDimensions}
maxHeight={config.thumbnailNavigation.height}
maxWidth={style.width}
aspectRatio={manifestoCanvas.aspectRatio}
......@@ -103,8 +104,8 @@ export class ThumbnailNavigation extends Component {
const { config, canvasGroupings } = this.props;
return canvasGroupings
.getCanvases(options.index)
.map(canvas => new ManifestoCanvas(canvas).aspectRatio)
.reduce((acc, current) => acc + Math.floor(config.thumbnailNavigation.height * current), 8);
.map(canvas => new ManifestoCanvas(canvas))
.reduce((acc, currentCanvas) => { return acc + (currentCanvas.hasValidDimensions ? Math.floor(config.thumbnailNavigation.height * currentCanvas.aspectRatio) : config.thumbnailNavigation.width); }, 8); // eslint-disable-line arrow-body-style, max-len
}
/**
......
......@@ -21,7 +21,6 @@ export class WindowSideBarCanvasPanel extends Component {
} = this.props;
const canvasesIdAndLabel = getIdAndLabelOfCanvases(canvases);
return (
<>
<Typography variant="h2" className={classes.windowSideBarH2}>{t('canvasIndex')}</Typography>
......
......@@ -38,6 +38,7 @@ export default {
thumbnailNavigation: {
defaultPosition: 'bottom',
height: 150,
width: 100,
},
workspace: {
type: 'mosaic',
......
......@@ -39,6 +39,36 @@ export default class ManifestoCanvas {
}/info.json`;
}
/**
* checks whether the canvas has a valid height
*/
get hasValidHeight() {
return (
typeof this.canvas.getHeight() === 'number'
&& this.canvas.getHeight() > 0
);
}
/**
* checks whether the canvas has a valid height
*/
get hasValidWidth() {
return (
typeof this.canvas.getHeight() === 'number'
&& this.canvas.getHeight() > 0
);
}
/**
* checks whether the canvas has valid dimensions
*/
get hasValidDimensions() {
return (
this.hasValidHeight
&& this.hasValidWidth
);
}
/**
* Creates a canonical image request for a thumb
* @param {Number} height
......@@ -79,34 +109,4 @@ export default class ManifestoCanvas {
return desiredAspectRatio < aspectRatio ? 'sizeByW' : 'sizeByH';
}
/**
* checks whether the canvas has a valid height
*/
get hasValidHeight() {
return (
typeof this.canvas.getHeight() === 'number'
&& this.canvas.getHeight() > 0
);
}
/**
* checks whether the canvas has a valid height
*/
get hasValidWidth() {
return (
typeof this.canvas.getHeight() === 'number'
&& this.canvas.getHeight() > 0
);
}
/**
* checks whether the canvas has valid dimensions
*/
get hasValidDimensions() {
return (
this.hasValidHeight
&& this.hasValidWidth
);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment