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:
Michael Telatynski 2017-04-21 13:01:10 +01:00
parent 9c27075175
commit 20abb2c2df

View File

@ -16,13 +16,13 @@ limitations under the License.
'use strict';
var React = require('react');
const React = require('react');
var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg');
var dis = require('matrix-react-sdk/lib/dispatcher');
var sdk = require('matrix-react-sdk');
var Modal = require('matrix-react-sdk/lib/Modal');
var Resend = require("matrix-react-sdk/lib/Resend");
const MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg');
const dis = require('matrix-react-sdk/lib/dispatcher');
const sdk = require('matrix-react-sdk');
const Modal = require('matrix-react-sdk/lib/Modal');
const Resend = require("matrix-react-sdk/lib/Resend");
import * as UserSettingsStore from 'matrix-react-sdk/lib/UserSettingsStore';
module.exports = React.createClass({
@ -45,7 +45,7 @@ module.exports = React.createClass({
},
onViewSourceClick: function() {
var ViewSource = sdk.getComponent('structures.ViewSource');
const ViewSource = sdk.getComponent('structures.ViewSource');
Modal.createDialog(ViewSource, {
content: this.props.mxEvent.event,
}, 'mx_Dialog_viewsource');
@ -70,12 +70,12 @@ module.exports = React.createClass({
MatrixClientPeg.get().redactEvent(
this.props.mxEvent.getRoomId(), this.props.mxEvent.getId()
).catch(function(e) {
var ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog");
// display error message stating you couldn't delete this.
var code = e.errcode || e.statusCode;
const code = e.errcode || e.statusCode;
Modal.createDialog(ErrorDialog, {
title: "Error",
description: "You cannot delete this message. (" + code + ")"
description: "You cannot delete this message. (" + code + ")",
});
}).done();
},
@ -88,6 +88,14 @@ module.exports = React.createClass({
if (this.props.onFinished) this.props.onFinished();
},
onForwardClick: function() {
dis.dispatch({
action: 'forward_message',
content: this.props.mxEvent.getContent(),
});
this.closeMenu();
},
closeMenu: function() {
if (this.props.onFinished) this.props.onFinished();
},
@ -99,7 +107,7 @@ module.exports = React.createClass({
if (this.props.onFinished) this.props.onFinished();
},
onQuoteClick: function () {
onQuoteClick: function() {
console.log(this.props.mxEvent);
dis.dispatch({
action: 'quote',
@ -108,15 +116,16 @@ module.exports = React.createClass({
},
render: function() {
var eventStatus = this.props.mxEvent.status;
var resendButton;
var viewSourceButton;
var viewClearSourceButton;
var redactButton;
var cancelButton;
var permalinkButton;
var unhidePreviewButton;
var externalURLButton;
const eventStatus = this.props.mxEvent.status;
let resendButton;
let redactButton;
let cancelButton;
let forwardButton;
let viewSourceButton;
let viewClearSourceButton;
let unhidePreviewButton;
let permalinkButton;
let externalURLButton;
if (eventStatus === 'not_sent') {
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 = (
<div className="mx_MessageContextMenu_field" onClick={this.onViewSourceClick}>
View Source
@ -162,7 +179,7 @@ module.exports = React.createClass({
<div className="mx_MessageContextMenu_field" onClick={this.onUnhidePreviewClick}>
Unhide Preview
</div>
)
);
}
}
@ -196,6 +213,7 @@ module.exports = React.createClass({
{resendButton}
{redactButton}
{cancelButton}
{forwardButton}
{viewSourceButton}
{viewClearSourceButton}
{unhidePreviewButton}
@ -204,5 +222,5 @@ module.exports = React.createClass({
{externalURLButton}
</div>
);
}
},
});