Changed the ViewImageModal to only store info for the current image
Этот коммит содержится в:
@@ -40,7 +40,7 @@ export default class ViewImageModal extends React.Component {
|
|||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
imgId: this.props.startId,
|
imgId: this.props.startId,
|
||||||
fileInfo: new Map(),
|
fileInfo: null,
|
||||||
imgHeight: '100%',
|
imgHeight: '100%',
|
||||||
loaded,
|
loaded,
|
||||||
progress,
|
progress,
|
||||||
@@ -109,12 +109,16 @@ export default class ViewImageModal extends React.Component {
|
|||||||
onFileStoreChange(filename) {
|
onFileStoreChange(filename) {
|
||||||
const id = this.props.filenames.indexOf(filename);
|
const id = this.props.filenames.indexOf(filename);
|
||||||
|
|
||||||
if (id !== -1 && !this.state.loaded[id]) {
|
if (id !== -1) {
|
||||||
const fileInfo = this.state.fileInfo;
|
if (id === this.state.imgId) {
|
||||||
fileInfo.set(filename, FileStore.getInfo(filename));
|
this.setState({
|
||||||
this.setState({fileInfo});
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
fileInfo: FileStore.getInfo(filename)
|
||||||
|
});
|
||||||
|
|
||||||
if (!this.state.loaded[id]) {
|
if (!this.state.loaded[id]) {
|
||||||
this.loadImage(id, filename);
|
this.loadImage(id, filename);
|
||||||
}
|
}
|
||||||
@@ -227,8 +235,8 @@ export default class ViewImageModal extends React.Component {
|
|||||||
|
|
||||||
var content;
|
var content;
|
||||||
if (this.state.loaded[this.state.imgId]) {
|
if (this.state.loaded[this.state.imgId]) {
|
||||||
// if a file has been loaded, we also have its info
|
// this.state.fileInfo is for the current image and we shoudl have it before we load the image
|
||||||
const fileInfo = this.state.fileInfo.get(filename);
|
const fileInfo = this.state.fileInfo;
|
||||||
|
|
||||||
const extension = Utils.splitFileLocation(filename).ext;
|
const extension = Utils.splitFileLocation(filename).ext;
|
||||||
const fileType = Utils.getFileType(extension);
|
const fileType = Utils.getFileType(extension);
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user