s/Quote/Reply/ and ES6 tweaks

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2017-12-17 20:20:45 +00:00
parent 9baf71c4fc
commit 9603b21199
No known key found for this signature in database
GPG key ID: 3F879DA5AD802A5E
5 changed files with 30 additions and 36 deletions

View file

@ -40,38 +40,36 @@ function wantsDateSeparator(parentEvent, event) {
return parentEventDate.getDay() !== eventDate.getDay(); return parentEventDate.getDay() !== eventDate.getDay();
} }
const Quote = React.createClass({ export default class Quote extends React.Component {
statics: { static isMessageUrl(url) {
isMessageUrl: (url) => { return !!REGEX_LOCAL_MATRIXTO.exec(url);
return !!REGEX_LOCAL_MATRIXTO.exec(url); }
},
},
childContextTypes: { static childContextTypes = {
matrixClient: React.PropTypes.object, matrixClient: PropTypes.object,
}, };
props: { static propTypes = {
// The matrix.to url of the event // The matrix.to url of the event
url: PropTypes.string, url: PropTypes.string,
// The parent event // The parent event
parentEv: PropTypes.instanceOf(MatrixEvent), parentEv: PropTypes.instanceOf(MatrixEvent),
// Whether to include an avatar in the pill };
shouldShowPillAvatar: PropTypes.bool,
},
getChildContext: function() { constructor(props, context) {
return { super(props, context);
matrixClient: MatrixClientPeg.get(),
};
},
getInitialState() { this.state = {
return {
// The event related to this quote // The event related to this quote
event: null, event: null,
}; };
}, }
getChildContext() {
return {
matrixClient: MatrixClientPeg.get(),
};
}
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
let roomId; let roomId;
@ -96,11 +94,11 @@ const Quote = React.createClass({
// Only try and load the event if we know about the room // 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. // otherwise we just leave a `Quote` anchor which can be used to navigate/join the room manually.
if (room) this.getEvent(room, eventId); if (room) this.getEvent(room, eventId);
}, }
componentWillMount() { componentWillMount() {
this.componentWillReceiveProps(this.props); this.componentWillReceiveProps(this.props);
}, }
async getEvent(room, eventId) { async getEvent(room, eventId) {
let event = room.findEventById(eventId); let event = room.findEventById(eventId);
@ -112,9 +110,9 @@ const Quote = React.createClass({
await MatrixClientPeg.get().getEventTimeline(room.getUnfilteredTimelineSet(), eventId); await MatrixClientPeg.get().getEventTimeline(room.getUnfilteredTimelineSet(), eventId);
event = room.findEventById(eventId); event = room.findEventById(eventId);
this.setState({room, event}); this.setState({room, event});
}, }
render: function() { render() {
const ev = this.state.event; const ev = this.state.event;
if (ev) { if (ev) {
const EventTile = sdk.getComponent('views.rooms.EventTile'); const EventTile = sdk.getComponent('views.rooms.EventTile');
@ -135,7 +133,5 @@ const Quote = React.createClass({
<a href={this.props.url}>{ _t('Quote') }</a> <a href={this.props.url}>{ _t('Quote') }</a>
<br /> <br />
</div>; </div>;
}, }
}); }
export default Quote;

View file

@ -209,7 +209,7 @@ module.exports = React.createClass({
const quoteContainer = document.createElement('span'); const quoteContainer = document.createElement('span');
const quote = const quote =
<Quote url={href} parentEv={this.props.mxEvent} shouldShowPillAvatar={shouldShowPillAvatar} />; <Quote url={href} parentEv={this.props.mxEvent} />;
ReactDOM.render(quote, quoteContainer); ReactDOM.render(quote, quoteContainer);
node.parentNode.replaceChild(quoteContainer, node); node.parentNode.replaceChild(quoteContainer, node);

View file

@ -64,9 +64,7 @@ export default class QuotePreview extends React.Component {
return <div className="mx_QuotePreview"> return <div className="mx_QuotePreview">
<div className="mx_QuotePreview_section"> <div className="mx_QuotePreview_section">
<EmojiText element="div" className="mx_QuotePreview_header mx_QuotePreview_title"> <EmojiText element="div" className="mx_QuotePreview_header mx_QuotePreview_title">
<span> { '💬' + _t('Replying') }
💬 { _t('Quoting') }
</span>
</EmojiText> </EmojiText>
<div className="mx_QuotePreview_header mx_QuotePreview_cancel"> <div className="mx_QuotePreview_header mx_QuotePreview_cancel">
<img className="mx_filterFlipColor" src="img/cancel.svg" width="18" height="18" <img className="mx_filterFlipColor" src="img/cancel.svg" width="18" height="18"

View file

@ -940,6 +940,6 @@
"The export file will be protected with a passphrase. You should enter the passphrase here, to decrypt the file.": "The export file will be protected with a passphrase. You should enter the passphrase here, to decrypt the file.", "The export file will be protected with a passphrase. You should enter the passphrase here, to decrypt the file.": "The export file will be protected with a passphrase. You should enter the passphrase here, to decrypt the file.",
"File to import": "File to import", "File to import": "File to import",
"Import": "Import", "Import": "Import",
"Quoting": "Quoting", "Message Replies": "Message Replies",
"Rich Quoting": "Rich Quoting" "Replying": "Replying"
} }

View file

@ -78,7 +78,7 @@ export const SETTINGS = {
// }, // },
"feature_rich_quoting": { "feature_rich_quoting": {
isFeature: true, isFeature: true,
displayName: _td("Rich Quoting"), displayName: _td("Message Replies"),
supportedLevels: LEVELS_FEATURE, supportedLevels: LEVELS_FEATURE,
default: false, default: false,
}, },