diff --git a/src/components/views/context_menus/MessageContextMenu.js b/src/components/views/context_menus/MessageContextMenu.js index 84bebc1341..62bffa7621 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 = (