You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-11-05 23:10:41 +03:00
Also only download images after clicking on them
This commit is contained in:
@@ -85,6 +85,7 @@ export default class MImageBody extends React.Component {
|
|||||||
showImage() {
|
showImage() {
|
||||||
localStorage.setItem("mx_ShowImage_" + this.props.mxEvent.getId(), "true");
|
localStorage.setItem("mx_ShowImage_" + this.props.mxEvent.getId(), "true");
|
||||||
this.setState({showImage: true});
|
this.setState({showImage: true});
|
||||||
|
this._downloadImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
onClick(ev) {
|
onClick(ev) {
|
||||||
@@ -253,10 +254,7 @@ export default class MImageBody extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
_downloadImage() {
|
||||||
this.unmounted = false;
|
|
||||||
this.context.on('sync', this.onClientSync);
|
|
||||||
|
|
||||||
const content = this.props.mxEvent.getContent();
|
const content = this.props.mxEvent.getContent();
|
||||||
if (content.file !== undefined && this.state.decryptedUrl === null) {
|
if (content.file !== undefined && this.state.decryptedUrl === null) {
|
||||||
let thumbnailPromise = Promise.resolve(null);
|
let thumbnailPromise = Promise.resolve(null);
|
||||||
@@ -289,9 +287,18 @@ export default class MImageBody extends React.Component {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Remember that the user wanted to show this particular image
|
componentDidMount() {
|
||||||
if (!this.state.showImage && localStorage.getItem("mx_ShowImage_" + this.props.mxEvent.getId()) === "true") {
|
this.unmounted = false;
|
||||||
|
this.context.on('sync', this.onClientSync);
|
||||||
|
|
||||||
|
const showImage = this.state.showImage ||
|
||||||
|
localStorage.getItem("mx_ShowImage_" + this.props.mxEvent.getId()) === "true";
|
||||||
|
|
||||||
|
if (showImage) {
|
||||||
|
// Don't download anything becaue we don't want to display anything.
|
||||||
|
this._downloadImage();
|
||||||
this.setState({showImage: true});
|
this.setState({showImage: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user