From 9603b21199a080cbcae58a22e312afa396094fe6 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Sun, 17 Dec 2017 20:20:45 +0000 Subject: [PATCH] s/Quote/Reply/ and ES6 tweaks Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/elements/Quote.js | 54 +++++++++----------- src/components/views/messages/TextualBody.js | 2 +- src/components/views/rooms/QuotePreview.js | 4 +- src/i18n/strings/en_EN.json | 4 +- src/settings/Settings.js | 2 +- 5 files changed, 30 insertions(+), 36 deletions(-) diff --git a/src/components/views/elements/Quote.js b/src/components/views/elements/Quote.js index a417e9a6de..f1fa3bdbac 100644 --- a/src/components/views/elements/Quote.js +++ b/src/components/views/elements/Quote.js @@ -40,38 +40,36 @@ function wantsDateSeparator(parentEvent, event) { return parentEventDate.getDay() !== eventDate.getDay(); } -const Quote = React.createClass({ - statics: { - isMessageUrl: (url) => { - return !!REGEX_LOCAL_MATRIXTO.exec(url); - }, - }, +export default class Quote extends React.Component { + static isMessageUrl(url) { + return !!REGEX_LOCAL_MATRIXTO.exec(url); + } - childContextTypes: { - matrixClient: React.PropTypes.object, - }, + static childContextTypes = { + matrixClient: PropTypes.object, + }; - props: { + static propTypes = { // The matrix.to url of the event url: PropTypes.string, // The parent event parentEv: PropTypes.instanceOf(MatrixEvent), - // Whether to include an avatar in the pill - shouldShowPillAvatar: PropTypes.bool, - }, + }; - getChildContext: function() { - return { - matrixClient: MatrixClientPeg.get(), - }; - }, + constructor(props, context) { + super(props, context); - getInitialState() { - return { + this.state = { // The event related to this quote event: null, }; - }, + } + + getChildContext() { + return { + matrixClient: MatrixClientPeg.get(), + }; + } componentWillReceiveProps(nextProps) { let roomId; @@ -96,11 +94,11 @@ const Quote = React.createClass({ // Only try and load the event if we know about the room // otherwise we just leave a `Quote` anchor which can be used to navigate/join the room manually. if (room) this.getEvent(room, eventId); - }, + } componentWillMount() { this.componentWillReceiveProps(this.props); - }, + } async getEvent(room, eventId) { let event = room.findEventById(eventId); @@ -112,9 +110,9 @@ const Quote = React.createClass({ await MatrixClientPeg.get().getEventTimeline(room.getUnfilteredTimelineSet(), eventId); event = room.findEventById(eventId); this.setState({room, event}); - }, + } - render: function() { + render() { const ev = this.state.event; if (ev) { const EventTile = sdk.getComponent('views.rooms.EventTile'); @@ -135,7 +133,5 @@ const Quote = React.createClass({ { _t('Quote') }
; - }, -}); - -export default Quote; + } +} diff --git a/src/components/views/messages/TextualBody.js b/src/components/views/messages/TextualBody.js index adf79d3135..54576fa794 100644 --- a/src/components/views/messages/TextualBody.js +++ b/src/components/views/messages/TextualBody.js @@ -209,7 +209,7 @@ module.exports = React.createClass({ const quoteContainer = document.createElement('span'); const quote = - ; + ; ReactDOM.render(quote, quoteContainer); node.parentNode.replaceChild(quoteContainer, node); diff --git a/src/components/views/rooms/QuotePreview.js b/src/components/views/rooms/QuotePreview.js index 7241feeac6..a76c9e2d1a 100644 --- a/src/components/views/rooms/QuotePreview.js +++ b/src/components/views/rooms/QuotePreview.js @@ -64,9 +64,7 @@ export default class QuotePreview extends React.Component { return
- - 💬 { _t('Quoting') } - + { '💬' + _t('Replying') }