Add Forward Message button to m.room.message events
Conform this file to eslint Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
9c27075175
commit
20abb2c2df
|
@ -16,13 +16,13 @@ limitations under the License.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var React = require('react');
|
const React = require('react');
|
||||||
|
|
||||||
var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg');
|
const MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg');
|
||||||
var dis = require('matrix-react-sdk/lib/dispatcher');
|
const dis = require('matrix-react-sdk/lib/dispatcher');
|
||||||
var sdk = require('matrix-react-sdk');
|
const sdk = require('matrix-react-sdk');
|
||||||
var Modal = require('matrix-react-sdk/lib/Modal');
|
const Modal = require('matrix-react-sdk/lib/Modal');
|
||||||
var Resend = require("matrix-react-sdk/lib/Resend");
|
const Resend = require("matrix-react-sdk/lib/Resend");
|
||||||
import * as UserSettingsStore from 'matrix-react-sdk/lib/UserSettingsStore';
|
import * as UserSettingsStore from 'matrix-react-sdk/lib/UserSettingsStore';
|
||||||
|
|
||||||
module.exports = React.createClass({
|
module.exports = React.createClass({
|
||||||
|
@ -45,7 +45,7 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
onViewSourceClick: function() {
|
onViewSourceClick: function() {
|
||||||
var ViewSource = sdk.getComponent('structures.ViewSource');
|
const ViewSource = sdk.getComponent('structures.ViewSource');
|
||||||
Modal.createDialog(ViewSource, {
|
Modal.createDialog(ViewSource, {
|
||||||
content: this.props.mxEvent.event,
|
content: this.props.mxEvent.event,
|
||||||
}, 'mx_Dialog_viewsource');
|
}, 'mx_Dialog_viewsource');
|
||||||
|
@ -70,12 +70,12 @@ module.exports = React.createClass({
|
||||||
MatrixClientPeg.get().redactEvent(
|
MatrixClientPeg.get().redactEvent(
|
||||||
this.props.mxEvent.getRoomId(), this.props.mxEvent.getId()
|
this.props.mxEvent.getRoomId(), this.props.mxEvent.getId()
|
||||||
).catch(function(e) {
|
).catch(function(e) {
|
||||||
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
|
||||||
// display error message stating you couldn't delete this.
|
// display error message stating you couldn't delete this.
|
||||||
var code = e.errcode || e.statusCode;
|
const code = e.errcode || e.statusCode;
|
||||||
Modal.createDialog(ErrorDialog, {
|
Modal.createDialog(ErrorDialog, {
|
||||||
title: "Error",
|
title: "Error",
|
||||||
description: "You cannot delete this message. (" + code + ")"
|
description: "You cannot delete this message. (" + code + ")",
|
||||||
});
|
});
|
||||||
}).done();
|
}).done();
|
||||||
},
|
},
|
||||||
|
@ -88,6 +88,14 @@ module.exports = React.createClass({
|
||||||
if (this.props.onFinished) this.props.onFinished();
|
if (this.props.onFinished) this.props.onFinished();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onForwardClick: function() {
|
||||||
|
dis.dispatch({
|
||||||
|
action: 'forward_message',
|
||||||
|
content: this.props.mxEvent.getContent(),
|
||||||
|
});
|
||||||
|
this.closeMenu();
|
||||||
|
},
|
||||||
|
|
||||||
closeMenu: function() {
|
closeMenu: function() {
|
||||||
if (this.props.onFinished) this.props.onFinished();
|
if (this.props.onFinished) this.props.onFinished();
|
||||||
},
|
},
|
||||||
|
@ -99,7 +107,7 @@ module.exports = React.createClass({
|
||||||
if (this.props.onFinished) this.props.onFinished();
|
if (this.props.onFinished) this.props.onFinished();
|
||||||
},
|
},
|
||||||
|
|
||||||
onQuoteClick: function () {
|
onQuoteClick: function() {
|
||||||
console.log(this.props.mxEvent);
|
console.log(this.props.mxEvent);
|
||||||
dis.dispatch({
|
dis.dispatch({
|
||||||
action: 'quote',
|
action: 'quote',
|
||||||
|
@ -108,15 +116,16 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
var eventStatus = this.props.mxEvent.status;
|
const eventStatus = this.props.mxEvent.status;
|
||||||
var resendButton;
|
let resendButton;
|
||||||
var viewSourceButton;
|
let redactButton;
|
||||||
var viewClearSourceButton;
|
let cancelButton;
|
||||||
var redactButton;
|
let forwardButton;
|
||||||
var cancelButton;
|
let viewSourceButton;
|
||||||
var permalinkButton;
|
let viewClearSourceButton;
|
||||||
var unhidePreviewButton;
|
let unhidePreviewButton;
|
||||||
var externalURLButton;
|
let permalinkButton;
|
||||||
|
let externalURLButton;
|
||||||
|
|
||||||
if (eventStatus === 'not_sent') {
|
if (eventStatus === 'not_sent') {
|
||||||
resendButton = (
|
resendButton = (
|
||||||
|
@ -142,6 +151,14 @@ module.exports = React.createClass({
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.props.mxEvent.getType() === 'm.room.message') {
|
||||||
|
forwardButton = (
|
||||||
|
<div className="mx_MessageContextMenu_field" onClick={this.onForwardClick}>
|
||||||
|
Forward Message
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
viewSourceButton = (
|
viewSourceButton = (
|
||||||
<div className="mx_MessageContextMenu_field" onClick={this.onViewSourceClick}>
|
<div className="mx_MessageContextMenu_field" onClick={this.onViewSourceClick}>
|
||||||
View Source
|
View Source
|
||||||
|
@ -162,7 +179,7 @@ module.exports = React.createClass({
|
||||||
<div className="mx_MessageContextMenu_field" onClick={this.onUnhidePreviewClick}>
|
<div className="mx_MessageContextMenu_field" onClick={this.onUnhidePreviewClick}>
|
||||||
Unhide Preview
|
Unhide Preview
|
||||||
</div>
|
</div>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +202,7 @@ module.exports = React.createClass({
|
||||||
externalURLButton = (
|
externalURLButton = (
|
||||||
<div className="mx_MessageContextMenu_field">
|
<div className="mx_MessageContextMenu_field">
|
||||||
<a href={ this.props.mxEvent.event.content.external_url }
|
<a href={ this.props.mxEvent.event.content.external_url }
|
||||||
rel="noopener" target="_blank" onClick={ this.closeMenu }>Source URL</a>
|
rel="noopener" target="_blank" onClick={ this.closeMenu }>Source URL</a>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -196,6 +213,7 @@ module.exports = React.createClass({
|
||||||
{resendButton}
|
{resendButton}
|
||||||
{redactButton}
|
{redactButton}
|
||||||
{cancelButton}
|
{cancelButton}
|
||||||
|
{forwardButton}
|
||||||
{viewSourceButton}
|
{viewSourceButton}
|
||||||
{viewClearSourceButton}
|
{viewClearSourceButton}
|
||||||
{unhidePreviewButton}
|
{unhidePreviewButton}
|
||||||
|
@ -204,5 +222,5 @@ module.exports = React.createClass({
|
||||||
{externalURLButton}
|
{externalURLButton}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue