diff --git a/src/components/views/context_menus/MessageContextMenu.js b/src/components/views/context_menus/MessageContextMenu.js index 84bebc134..62bffa762 100644 --- a/src/components/views/context_menus/MessageContextMenu.js +++ b/src/components/views/context_menus/MessageContextMenu.js @@ -16,14 +16,14 @@ limitations under the License. 'use strict'; -const React = require('react'); +import React from 'react'; -const MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg'); -const dis = require('matrix-react-sdk/lib/dispatcher'); -const sdk = require('matrix-react-sdk'); +import MatrixClientPeg from 'matrix-react-sdk/lib/MatrixClientPeg'; +import dis from 'matrix-react-sdk/lib/dispatcher'; +import sdk from 'matrix-react-sdk'; import { _t } from 'matrix-react-sdk/lib/languageHandler'; -const Modal = require('matrix-react-sdk/lib/Modal'); -const Resend = require("matrix-react-sdk/lib/Resend"); +import Modal from 'matrix-react-sdk/lib/Modal'; +import Resend from "matrix-react-sdk/lib/Resend"; import SettingsStore from "matrix-react-sdk/lib/settings/SettingsStore"; import {makeEventPermalink} from 'matrix-react-sdk/lib/matrix-to'; @@ -108,15 +108,14 @@ module.exports = React.createClass({ onFinished: (proceed) => { if (!proceed) return; - MatrixClientPeg.get().redactEvent( - this.props.mxEvent.getRoomId(), this.props.mxEvent.getId() - ).catch(function(e) { + const cli = MatrixClientPeg.get(); + cli.redactEvent(this.props.mxEvent.getRoomId(), this.props.mxEvent.getId()).catch(function(e) { const ErrorDialog = sdk.getComponent("dialogs.ErrorDialog"); // display error message stating you couldn't delete this. const code = e.errcode || e.statusCode; Modal.createTrackedDialog('You cannot delete this message', '', ErrorDialog, { title: _t('Error'), - description: _t('You cannot delete this message. (%(code)s)', {code: code}) + description: _t('You cannot delete this message. (%(code)s)', {code}), }); }).done(); }, @@ -139,12 +138,12 @@ module.exports = React.createClass({ onPinClick: function() { MatrixClientPeg.get().getStateEvent(this.props.mxEvent.getRoomId(), 'm.room.pinned_events', '') - .catch(e => { + .catch((e) => { // Intercept the Event Not Found error and fall through the promise chain with no event. if (e.errcode === "M_NOT_FOUND") return null; throw e; }) - .then(event => { + .then((event) => { const eventIds = (event ? event.pinned : []) || []; if (!eventIds.includes(this.props.mxEvent.getId())) { // Not pinned - add @@ -154,7 +153,8 @@ module.exports = React.createClass({ eventIds.splice(eventIds.indexOf(this.props.mxEvent.getId()), 1); } - MatrixClientPeg.get().sendStateEvent(this.props.mxEvent.getRoomId(), 'm.room.pinned_events', {pinned: eventIds}, ''); + const cli = MatrixClientPeg.get(); + cli.sendStateEvent(this.props.mxEvent.getRoomId(), 'm.room.pinned_events', {pinned: eventIds}, ''); }); this.closeMenu(); }, @@ -193,10 +193,8 @@ module.exports = React.createClass({ let cancelButton; let forwardButton; let pinButton; - let viewSourceButton; let viewClearSourceButton; let unhidePreviewButton; - let permalinkButton; let externalURLButton; let quoteButton; let replyButton; @@ -237,14 +235,14 @@ module.exports = React.createClass({ if (this.state.canPin) { pinButton = (
- {this._isPinned() ? _t('Unpin Message') : _t('Pin Message')} + { this._isPinned() ? _t('Unpin Message') : _t('Pin Message') }
); } } } - viewSourceButton = ( + const viewSourceButton = (
{ _t('View Source') }
@@ -269,7 +267,7 @@ module.exports = React.createClass({ } // 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) - permalinkButton = ( + const permalinkButton = (
{ _t('Permalink') } @@ -293,30 +291,30 @@ module.exports = React.createClass({ } // Bridges can provide a 'external_url' to link back to the source. - if( typeof(this.props.mxEvent.event.content.external_url) === "string") { - externalURLButton = ( -
- { _t('Source URL') } -
- ); + if (typeof(this.props.mxEvent.event.content.external_url) === "string") { + externalURLButton = ( +
+ { _t('Source URL') } +
+ ); } return (
- {resendButton} - {redactButton} - {cancelButton} - {forwardButton} - {pinButton} - {viewSourceButton} - {viewClearSourceButton} - {unhidePreviewButton} - {permalinkButton} - {quoteButton} - {replyButton} - {externalURLButton} + { resendButton } + { redactButton } + { cancelButton } + { forwardButton } + { pinButton } + { viewSourceButton } + { viewClearSourceButton } + { unhidePreviewButton } + { permalinkButton } + { quoteButton } + { replyButton } + { externalURLButton }
); },