From d95f843cd0bf16adf17ba1c25c530c124b84241c Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Mon, 2 Mar 2020 17:52:20 -0700 Subject: [PATCH 1/2] Don't group blank membership changes We already drop noop membership changes when they don't make it into a MELS, so we just need to make the MELS aware enough to drop messages early that are noops. Fixes https://github.com/vector-im/riot-web/issues/12575 --- src/components/structures/MessagePanel.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/components/structures/MessagePanel.js b/src/components/structures/MessagePanel.js index dd47028f8e2..0029090a947 100644 --- a/src/components/structures/MessagePanel.js +++ b/src/components/structures/MessagePanel.js @@ -962,6 +962,17 @@ class MemberGrouper { } add(ev) { + if (ev.getType() === 'm.room.member') { + // We'll just double check that it's worth our time to do so... + if (ev.getPrevContent()) { + const membershipChange = ev.getPrevContent()['membership'] !== ev.getContent()['membership']; + const displayNameChange = ev.getPrevContent()['displayname'] !== ev.getContent()['displayname']; + const avatarChange = ev.getPrevContent()['avatar_url'] !== ev.getContent()['avatar_url']; + if (!membershipChange && !displayNameChange && !avatarChange) { + return; // Not a substantial change - quietly ignore + } + } + } this.readMarker = this.readMarker || this.panel._readMarkerForEvent(ev.getId()); this.events.push(ev); } From b06a82ee80b2aa656f1a0114c7fa2fab7fccc8dd Mon Sep 17 00:00:00 2001 From: Travis Ralston Date: Wed, 4 Mar 2020 11:44:12 -0700 Subject: [PATCH 2/2] Use textForEvent to determine if an event is worth rendering --- src/components/structures/MessagePanel.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/components/structures/MessagePanel.js b/src/components/structures/MessagePanel.js index 0029090a947..a2ac93d2823 100644 --- a/src/components/structures/MessagePanel.js +++ b/src/components/structures/MessagePanel.js @@ -28,6 +28,7 @@ import {MatrixClientPeg} from '../../MatrixClientPeg'; import SettingsStore from '../../settings/SettingsStore'; import {_t} from "../../languageHandler"; import {haveTileForEvent} from "../views/rooms/EventTile"; +import {textForEvent} from "../../TextForEvent"; const CONTINUATION_MAX_INTERVAL = 5 * 60 * 1000; // 5 minutes const continuedTypes = ['m.sticker', 'm.room.message']; @@ -963,15 +964,11 @@ class MemberGrouper { add(ev) { if (ev.getType() === 'm.room.member') { - // We'll just double check that it's worth our time to do so... - if (ev.getPrevContent()) { - const membershipChange = ev.getPrevContent()['membership'] !== ev.getContent()['membership']; - const displayNameChange = ev.getPrevContent()['displayname'] !== ev.getContent()['displayname']; - const avatarChange = ev.getPrevContent()['avatar_url'] !== ev.getContent()['avatar_url']; - if (!membershipChange && !displayNameChange && !avatarChange) { - return; // Not a substantial change - quietly ignore - } - } + // We'll just double check that it's worth our time to do so, through an + // ugly hack. If textForEvent returns something, we should group it for + // rendering but if it doesn't then we'll exclude it. + const renderText = textForEvent(ev); + if (!renderText || renderText.trim().length === 0) return; // quietly ignore } this.readMarker = this.readMarker || this.panel._readMarkerForEvent(ev.getId()); this.events.push(ev);