From 429b8e94dfdd3290da68e2f86e2c33f2b0aa3b92 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 3 Jul 2019 08:58:34 +0100 Subject: [PATCH] MELS handle m.room.third_party_invite Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/structures/MessagePanel.js | 6 +++--- .../views/elements/MemberEventListSummary.js | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/components/structures/MessagePanel.js b/src/components/structures/MessagePanel.js index 4238e22bd9..37a8a2d4c9 100644 --- a/src/components/structures/MessagePanel.js +++ b/src/components/structures/MessagePanel.js @@ -31,6 +31,8 @@ import SettingsStore from '../../settings/SettingsStore'; const CONTINUATION_MAX_INTERVAL = 5 * 60 * 1000; // 5 minutes const continuedTypes = ['m.sticker', 'm.room.message']; +const isMembershipChange = (e) => e.getType() === 'm.room.member' || e.getType() === 'm.room.third_party_invite'; + /* (almost) stateless UI component which builds the event tiles in the room timeline. */ module.exports = React.createClass({ @@ -375,8 +377,6 @@ module.exports = React.createClass({ this._readReceiptsByEvent = this._getReadReceiptsByShownEvent(); } - const isMembershipChange = (e) => e.getType() === 'm.room.member'; - for (i = 0; i < this.props.events.length; i++) { const mxEv = this.props.events[i]; const eventId = mxEv.getId(); @@ -444,7 +444,7 @@ module.exports = React.createClass({ // In order to prevent DateSeparators from appearing in the expanded form // of MemberEventListSummary, render each member event as if the previous // one was itself. This way, the timestamp of the previous event === the - // timestamp of the current event, and no DateSeperator is inserted. + // timestamp of the current event, and no DateSeparator is inserted. return this._getTilesForEvent(e, e, e === lastShownEvent); }).reduce((a, b) => a.concat(b)); diff --git a/src/components/views/elements/MemberEventListSummary.js b/src/components/views/elements/MemberEventListSummary.js index aacc1c7c18..9e48d780a9 100644 --- a/src/components/views/elements/MemberEventListSummary.js +++ b/src/components/views/elements/MemberEventListSummary.js @@ -313,6 +313,11 @@ module.exports = React.createClass({ * if a transition is not recognised. */ _getTransition: function(e) { + if (e.mxEvent.getType() === 'm.room.third_party_invite') { + // Handle 3pid invites the same as invites so they get bundled together + return 'invited'; + } + switch (e.mxEvent.getContent().membership) { case 'invite': return 'invited'; case 'ban': return 'banned'; @@ -427,9 +432,17 @@ module.exports = React.createClass({ userEvents[userId] = []; if (e.target) avatarMembers.push(e.target); } + + let displayName = userId; + if (e.getType() === 'm.room.third_party_invite') { + displayName = e.getContent().display_name; + } else if (e.target) { + displayName = e.target.name; + } + userEvents[userId].push({ mxEvent: e, - displayName: (e.target ? e.target.name : null) || userId, + displayName, index: index, }); });