delint
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
304d281ed2
commit
2961e1949f
|
@ -16,14 +16,14 @@ limitations under the License.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const React = require('react');
|
import React from 'react';
|
||||||
|
|
||||||
const MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg');
|
import MatrixClientPeg from 'matrix-react-sdk/lib/MatrixClientPeg';
|
||||||
const dis = require('matrix-react-sdk/lib/dispatcher');
|
import dis from 'matrix-react-sdk/lib/dispatcher';
|
||||||
const sdk = require('matrix-react-sdk');
|
import sdk from 'matrix-react-sdk';
|
||||||
import { _t } from 'matrix-react-sdk/lib/languageHandler';
|
import { _t } from 'matrix-react-sdk/lib/languageHandler';
|
||||||
const Modal = require('matrix-react-sdk/lib/Modal');
|
import Modal from 'matrix-react-sdk/lib/Modal';
|
||||||
const Resend = require("matrix-react-sdk/lib/Resend");
|
import Resend from "matrix-react-sdk/lib/Resend";
|
||||||
import SettingsStore from "matrix-react-sdk/lib/settings/SettingsStore";
|
import SettingsStore from "matrix-react-sdk/lib/settings/SettingsStore";
|
||||||
import {makeEventPermalink} from 'matrix-react-sdk/lib/matrix-to';
|
import {makeEventPermalink} from 'matrix-react-sdk/lib/matrix-to';
|
||||||
|
|
||||||
|
@ -108,15 +108,14 @@ module.exports = React.createClass({
|
||||||
onFinished: (proceed) => {
|
onFinished: (proceed) => {
|
||||||
if (!proceed) return;
|
if (!proceed) return;
|
||||||
|
|
||||||
MatrixClientPeg.get().redactEvent(
|
const cli = MatrixClientPeg.get();
|
||||||
this.props.mxEvent.getRoomId(), this.props.mxEvent.getId()
|
cli.redactEvent(this.props.mxEvent.getRoomId(), this.props.mxEvent.getId()).catch(function(e) {
|
||||||
).catch(function(e) {
|
|
||||||
const 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.
|
||||||
const code = e.errcode || e.statusCode;
|
const code = e.errcode || e.statusCode;
|
||||||
Modal.createTrackedDialog('You cannot delete this message', '', ErrorDialog, {
|
Modal.createTrackedDialog('You cannot delete this message', '', ErrorDialog, {
|
||||||
title: _t('Error'),
|
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();
|
}).done();
|
||||||
},
|
},
|
||||||
|
@ -139,12 +138,12 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
onPinClick: function() {
|
onPinClick: function() {
|
||||||
MatrixClientPeg.get().getStateEvent(this.props.mxEvent.getRoomId(), 'm.room.pinned_events', '')
|
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.
|
// Intercept the Event Not Found error and fall through the promise chain with no event.
|
||||||
if (e.errcode === "M_NOT_FOUND") return null;
|
if (e.errcode === "M_NOT_FOUND") return null;
|
||||||
throw e;
|
throw e;
|
||||||
})
|
})
|
||||||
.then(event => {
|
.then((event) => {
|
||||||
const eventIds = (event ? event.pinned : []) || [];
|
const eventIds = (event ? event.pinned : []) || [];
|
||||||
if (!eventIds.includes(this.props.mxEvent.getId())) {
|
if (!eventIds.includes(this.props.mxEvent.getId())) {
|
||||||
// Not pinned - add
|
// Not pinned - add
|
||||||
|
@ -154,7 +153,8 @@ module.exports = React.createClass({
|
||||||
eventIds.splice(eventIds.indexOf(this.props.mxEvent.getId()), 1);
|
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();
|
this.closeMenu();
|
||||||
},
|
},
|
||||||
|
@ -193,10 +193,8 @@ module.exports = React.createClass({
|
||||||
let cancelButton;
|
let cancelButton;
|
||||||
let forwardButton;
|
let forwardButton;
|
||||||
let pinButton;
|
let pinButton;
|
||||||
let viewSourceButton;
|
|
||||||
let viewClearSourceButton;
|
let viewClearSourceButton;
|
||||||
let unhidePreviewButton;
|
let unhidePreviewButton;
|
||||||
let permalinkButton;
|
|
||||||
let externalURLButton;
|
let externalURLButton;
|
||||||
let quoteButton;
|
let quoteButton;
|
||||||
let replyButton;
|
let replyButton;
|
||||||
|
@ -237,14 +235,14 @@ module.exports = React.createClass({
|
||||||
if (this.state.canPin) {
|
if (this.state.canPin) {
|
||||||
pinButton = (
|
pinButton = (
|
||||||
<div className="mx_MessageContextMenu_field" onClick={this.onPinClick}>
|
<div className="mx_MessageContextMenu_field" onClick={this.onPinClick}>
|
||||||
{this._isPinned() ? _t('Unpin Message') : _t('Pin Message')}
|
{ this._isPinned() ? _t('Unpin Message') : _t('Pin Message') }
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
viewSourceButton = (
|
const viewSourceButton = (
|
||||||
<div className="mx_MessageContextMenu_field" onClick={this.onViewSourceClick}>
|
<div className="mx_MessageContextMenu_field" onClick={this.onViewSourceClick}>
|
||||||
{ _t('View Source') }
|
{ _t('View Source') }
|
||||||
</div>
|
</div>
|
||||||
|
@ -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)
|
// 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 = (
|
||||||
<div className="mx_MessageContextMenu_field">
|
<div className="mx_MessageContextMenu_field">
|
||||||
<a href={makeEventPermalink(this.props.mxEvent.getRoomId(), this.props.mxEvent.getId())}
|
<a href={makeEventPermalink(this.props.mxEvent.getRoomId(), this.props.mxEvent.getId())}
|
||||||
target="_blank" rel="noopener" onClick={this.closeMenu}>{ _t('Permalink') }</a>
|
target="_blank" rel="noopener" onClick={this.closeMenu}>{ _t('Permalink') }</a>
|
||||||
|
@ -293,30 +291,30 @@ module.exports = React.createClass({
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bridges can provide a 'external_url' to link back to the source.
|
// Bridges can provide a 'external_url' to link back to the source.
|
||||||
if( typeof(this.props.mxEvent.event.content.external_url) === "string") {
|
if (typeof(this.props.mxEvent.event.content.external_url) === "string") {
|
||||||
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 }>{ _t('Source URL') }</a>
|
rel="noopener" target="_blank" onClick={this.closeMenu}>{ _t('Source URL') }</a>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
{resendButton}
|
{ resendButton }
|
||||||
{redactButton}
|
{ redactButton }
|
||||||
{cancelButton}
|
{ cancelButton }
|
||||||
{forwardButton}
|
{ forwardButton }
|
||||||
{pinButton}
|
{ pinButton }
|
||||||
{viewSourceButton}
|
{ viewSourceButton }
|
||||||
{viewClearSourceButton}
|
{ viewClearSourceButton }
|
||||||
{unhidePreviewButton}
|
{ unhidePreviewButton }
|
||||||
{permalinkButton}
|
{ permalinkButton }
|
||||||
{quoteButton}
|
{ quoteButton }
|
||||||
{replyButton}
|
{ replyButton }
|
||||||
{externalURLButton}
|
{ externalURLButton }
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue