Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 7eb54cc

Browse files
committed
Also only download images after clicking on them
1 parent e5228e2 commit 7eb54cc

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/components/views/messages/MImageBody.js

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export default class MImageBody extends React.Component {
8585
showImage() {
8686
localStorage.setItem("mx_ShowImage_" + this.props.mxEvent.getId(), "true");
8787
this.setState({showImage: true});
88+
this._downloadImage();
8889
}
8990

9091
onClick(ev) {
@@ -253,10 +254,7 @@ export default class MImageBody extends React.Component {
253254
}
254255
}
255256

256-
componentDidMount() {
257-
this.unmounted = false;
258-
this.context.on('sync', this.onClientSync);
259-
257+
_downloadImage() {
260258
const content = this.props.mxEvent.getContent();
261259
if (content.file !== undefined && this.state.decryptedUrl === null) {
262260
let thumbnailPromise = Promise.resolve(null);
@@ -289,9 +287,18 @@ export default class MImageBody extends React.Component {
289287
});
290288
});
291289
}
290+
}
291+
292+
componentDidMount() {
293+
this.unmounted = false;
294+
this.context.on('sync', this.onClientSync);
295+
296+
const showImage = this.state.showImage ||
297+
localStorage.getItem("mx_ShowImage_" + this.props.mxEvent.getId()) === "true";
292298

293-
// Remember that the user wanted to show this particular image
294-
if (!this.state.showImage && localStorage.getItem("mx_ShowImage_" + this.props.mxEvent.getId()) === "true") {
299+
if (showImage) {
300+
// Don't download anything becaue we don't want to display anything.
301+
this._downloadImage();
295302
this.setState({showImage: true});
296303
}
297304

0 commit comments

Comments
 (0)