From a47d696b95ed613e2870fab430089929a7de5674 Mon Sep 17 00:00:00 2001 From: hmhealey Date: Mon, 4 Jan 2016 12:14:38 -0500 Subject: Changed the ViewImageModal to only store info for the current image --- web/react/components/view_image.jsx | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'web/react/components/view_image.jsx') diff --git a/web/react/components/view_image.jsx b/web/react/components/view_image.jsx index 7edf6283b..3d13f4ea1 100644 --- a/web/react/components/view_image.jsx +++ b/web/react/components/view_image.jsx @@ -40,7 +40,7 @@ export default class ViewImageModal extends React.Component { this.state = { imgId: this.props.startId, - fileInfo: new Map(), + fileInfo: null, imgHeight: '100%', loaded, progress, @@ -109,12 +109,16 @@ export default class ViewImageModal extends React.Component { onFileStoreChange(filename) { const id = this.props.filenames.indexOf(filename); - if (id !== -1 && !this.state.loaded[id]) { - const fileInfo = this.state.fileInfo; - fileInfo.set(filename, FileStore.getInfo(filename)); - this.setState({fileInfo}); + if (id !== -1) { + if (id === this.state.imgId) { + this.setState({ + fileInfo: FileStore.getInfo(filename) + }); + } - this.loadImage(id, filename); + if (!this.state.loaded[id]) { + this.loadImage(id, filename); + } } } @@ -132,6 +136,10 @@ export default class ViewImageModal extends React.Component { return; } + this.setState({ + fileInfo: FileStore.getInfo(filename) + }); + if (!this.state.loaded[id]) { this.loadImage(id, filename); } @@ -227,8 +235,8 @@ export default class ViewImageModal extends React.Component { var content; if (this.state.loaded[this.state.imgId]) { - // if a file has been loaded, we also have its info - const fileInfo = this.state.fileInfo.get(filename); + // this.state.fileInfo is for the current image and we shoudl have it before we load the image + const fileInfo = this.state.fileInfo; const extension = Utils.splitFileLocation(filename).ext; const fileType = Utils.getFileType(extension); -- cgit v1.2.3-1-g7c22 From 4b76d6a05d0142c9d1addca698a922e8929674e1 Mon Sep 17 00:00:00 2001 From: hmhealey Date: Mon, 4 Jan 2016 12:23:46 -0500 Subject: Fixed ViewImage modal to clear its loaded state when its file list changes --- web/react/components/view_image.jsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'web/react/components/view_image.jsx') diff --git a/web/react/components/view_image.jsx b/web/react/components/view_image.jsx index 3d13f4ea1..196a44bd0 100644 --- a/web/react/components/view_image.jsx +++ b/web/react/components/view_image.jsx @@ -31,19 +31,12 @@ export default class ViewImageModal extends React.Component { this.onMouseEnterImage = this.onMouseEnterImage.bind(this); this.onMouseLeaveImage = this.onMouseLeaveImage.bind(this); - const loaded = []; - const progress = []; - for (var i = 0; i < this.props.filenames.length; i++) { - loaded.push(false); - progress.push(0); - } - this.state = { imgId: this.props.startId, fileInfo: null, imgHeight: '100%', - loaded, - progress, + loaded: Utils.fillArray(false, this.props.filenames.length), + progress: Utils.fillArray(0, this.props.filenames.length), showFooter: false }; } @@ -104,6 +97,13 @@ export default class ViewImageModal extends React.Component { } else if (nextProps.show === false && this.props.show === true) { this.onModalHidden(); } + + if (!Utils.areObjectsEqual(this.props.filenames, nextProps.filenames)) { + this.setState({ + loaded: Utils.fillArray(false, nextProps.filenames.length), + progress: Utils.fillArray(0, nextProps.filenames.length) + }); + } } onFileStoreChange(filename) { -- cgit v1.2.3-1-g7c22