From 20abb2c2dfd15eb339d9730589cf65fada4299cb Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 21 Apr 2017 13:01:10 +0100 Subject: [PATCH] Add Forward Message button to m.room.message events Conform this file to eslint Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- .../views/context_menus/MessageContextMenu.js | 64 ++++++++++++------- 1 file changed, 41 insertions(+), 23 deletions(-) diff --git a/src/components/views/context_menus/MessageContextMenu.js b/src/components/views/context_menus/MessageContextMenu.js index db416b8a06..4a6c978892 100644 --- a/src/components/views/context_menus/MessageContextMenu.js +++ b/src/components/views/context_menus/MessageContextMenu.js @@ -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 = ( +
+ Forward Message +
+ ); + } + viewSourceButton = (
View Source @@ -162,7 +179,7 @@ module.exports = React.createClass({
Unhide Preview
- ) + ); } } @@ -185,7 +202,7 @@ module.exports = React.createClass({ externalURLButton = (
Source URL + rel="noopener" target="_blank" onClick={ this.closeMenu }>Source URL
); } @@ -196,6 +213,7 @@ module.exports = React.createClass({ {resendButton} {redactButton} {cancelButton} + {forwardButton} {viewSourceButton} {viewClearSourceButton} {unhidePreviewButton} @@ -204,5 +222,5 @@ module.exports = React.createClass({ {externalURLButton}
); - } + }, });