Skip to content

Commit ff28850

Browse files
committed
support cancelling and uncancelling previews
1 parent a525897 commit ff28850

2 files changed

Lines changed: 34 additions & 0 deletions

File tree

‎src/components/views/rooms/MessageContextMenu.js‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,23 @@ module.exports = React.createClass({
6666
if (this.props.onFinished) this.props.onFinished();
6767
},
6868

69+
onUnhidePreviewClick: function() {
70+
if (global.localStorage) {
71+
// FIXME: factor this out with LinkPreviewWidget
72+
// FIXME: somehow propagate this to the EventTile such that it updates itself and realises the link has rematerialised
73+
global.localStorage.removeItem("hide_preview_" + this.props.mxEvent.getId());
74+
if (this.props.onFinished) this.props.onFinished();
75+
}
76+
},
77+
6978
render: function() {
7079
var eventStatus = this.props.mxEvent.status;
7180
var resendButton;
7281
var viewSourceButton;
7382
var redactButton;
7483
var cancelButton;
7584
var permalinkButton;
85+
var unhidePreviewButton;
7686

7787
if (eventStatus === 'not_sent') {
7888
resendButton = (
@@ -104,6 +114,18 @@ module.exports = React.createClass({
104114
</div>
105115
);
106116

117+
118+
if (global.localStorage) {
119+
// FIXME: factor this out with LinkPreviewWidget
120+
if (global.localStorage.getItem("hide_preview_" + this.props.mxEvent.getId()) === "1") {
121+
unhidePreviewButton = (
122+
<div className="mx_ContextualMenu_field" onClick={this.onUnhidePreviewClick}>
123+
Unhide Preview
124+
</div>
125+
)
126+
}
127+
}
128+
107129
// XXX: this should be https://matrix.to.
108130
// XXX: if we use room ID, we should also include a server where the event can be found (other than in the domain of the event ID)
109131
permalinkButton = (
@@ -119,6 +141,7 @@ module.exports = React.createClass({
119141
{redactButton}
120142
{cancelButton}
121143
{viewSourceButton}
144+
{unhidePreviewButton}
122145
{permalinkButton}
123146
</div>
124147
);

‎src/skins/vector/css/matrix-react-sdk/views/rooms/UrlPreviewWidget.css‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ limitations under the License.
3333

3434
.mx_LinkPreviewWidget_caption {
3535
margin-left: 15px;
36+
-webkit-flex: 1;
37+
flex: 1;
3638
}
3739

3840
.mx_LinkPreviewWidget_title {
@@ -48,3 +50,12 @@ limitations under the License.
4850
margin-top: 8px;
4951
white-space: normal;
5052
}
53+
54+
.mx_LinkPreviewWidget_cancel {
55+
visibility: hidden;
56+
cursor: pointer;
57+
}
58+
59+
.mx_LinkPreviewWidget:hover .mx_LinkPreviewWidget_cancel {
60+
visibility: visible;
61+
}

0 commit comments

Comments
 (0)