ugly impl to track whether to hide the widget or not
This commit is contained in:
parent
e61c99f7f3
commit
0eb7b627fc
2 changed files with 38 additions and 19 deletions
|
@ -32,6 +32,7 @@ module.exports = React.createClass({
|
|||
propTypes: {
|
||||
link: React.PropTypes.string.isRequired,
|
||||
mxEvent: React.PropTypes.object.isRequired,
|
||||
onCancelClick: React.PropTypes.func,
|
||||
onWidgetLoad: React.PropTypes.func,
|
||||
},
|
||||
|
||||
|
@ -42,12 +43,6 @@ module.exports = React.createClass({
|
|||
},
|
||||
|
||||
componentWillMount: function() {
|
||||
if (global.localStorage) {
|
||||
if (global.localStorage.getItem("hide_preview_" + this.props.mxEvent.getId()) === "1") {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
MatrixClientPeg.get().getUrlPreview(this.props.link, this.props.mxEvent.getTs()).then((res)=>{
|
||||
this.setState({ preview: res });
|
||||
this.props.onWidgetLoad();
|
||||
|
@ -66,15 +61,6 @@ module.exports = React.createClass({
|
|||
linkifyElement(this.refs.description, linkifyMatrix.options);
|
||||
},
|
||||
|
||||
onCancelClick: function(event) {
|
||||
this.setState({ preview: null });
|
||||
// FIXME: persist this somewhere smarter than local storage
|
||||
// FIXME: add to event contextual menu ability to unhide hidden previews
|
||||
if (global.localStorage) {
|
||||
global.localStorage.setItem("hide_preview_" + this.props.mxEvent.getId(), "1");
|
||||
}
|
||||
},
|
||||
|
||||
render: function() {
|
||||
var p = this.state.preview;
|
||||
if (!p) return <div/>;
|
||||
|
@ -109,7 +95,7 @@ module.exports = React.createClass({
|
|||
</div>
|
||||
</div>
|
||||
<img className="mx_LinkPreviewWidget_cancel" src="img/cancel.svg" width="18" height="18"
|
||||
onClick={ this.onCancelClick }/>
|
||||
onClick={ this.props.onCancelClick }/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue