diff --git a/src/components/views/messages/TextualBody.js b/src/components/views/messages/TextualBody.js
index d13111bcc6..dff6772af2 100644
--- a/src/components/views/messages/TextualBody.js
+++ b/src/components/views/messages/TextualBody.js
@@ -91,7 +91,7 @@ module.exports = React.createClass({
var widget;
if (this.state.link) {
var LinkPreviewWidget = sdk.getComponent('rooms.LinkPreviewWidget');
- widget = ;
+ widget = ;
}
switch (content.msgtype) {
diff --git a/src/components/views/rooms/LinkPreviewWidget.js b/src/components/views/rooms/LinkPreviewWidget.js
index 80e03522a4..266ec36ecf 100644
--- a/src/components/views/rooms/LinkPreviewWidget.js
+++ b/src/components/views/rooms/LinkPreviewWidget.js
@@ -31,7 +31,7 @@ module.exports = React.createClass({
propTypes: {
link: React.PropTypes.string.isRequired,
- ts: React.PropTypes.number,
+ mxEvent: React.PropTypes.object.isRequired,
onWidgetLoad: React.PropTypes.func,
},
@@ -42,7 +42,13 @@ module.exports = React.createClass({
},
componentWillMount: function() {
- MatrixClientPeg.get().getUrlPreview(this.props.link, this.props.ts).then((res)=>{
+ 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();
}, (error)=>{
@@ -60,6 +66,15 @@ 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
;
@@ -93,6 +108,8 @@ module.exports = React.createClass({
{ p["og:description"] }
+
);
}