summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorhmhealey <harrisonmhealey@gmail.com>2016-01-04 12:23:46 -0500
committerhmhealey <harrisonmhealey@gmail.com>2016-01-04 12:23:46 -0500
commit4b76d6a05d0142c9d1addca698a922e8929674e1 (patch)
tree554add4224da338fa4ed31281db81c8e47d9cfe5 /web
parenta47d696b95ed613e2870fab430089929a7de5674 (diff)
downloadchat-4b76d6a05d0142c9d1addca698a922e8929674e1.tar.gz
chat-4b76d6a05d0142c9d1addca698a922e8929674e1.tar.bz2
chat-4b76d6a05d0142c9d1addca698a922e8929674e1.zip
Fixed ViewImage modal to clear its loaded state when its file list changes
Diffstat (limited to 'web')
-rw-r--r--web/react/components/view_image.jsx18
-rw-r--r--web/react/utils/utils.jsx10
2 files changed, 19 insertions, 9 deletions
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) {
diff --git a/web/react/utils/utils.jsx b/web/react/utils/utils.jsx
index 24d27b10a..a808c9be3 100644
--- a/web/react/utils/utils.jsx
+++ b/web/react/utils/utils.jsx
@@ -1261,3 +1261,13 @@ export function isFeatureEnabled(feature) {
export function isSystemMessage(post) {
return post.type && (post.type.lastIndexOf(Constants.SYSTEM_MESSAGE_PREFIX) === 0);
}
+
+export function fillArray(value, length) {
+ const arr = [];
+
+ for (let i = 0; i < length; i++) {
+ arr.push(value);
+ }
+
+ return arr;
+}