From f3641eaa32d570a9ab64d49142248a2abd4df116 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Sun, 23 Jun 2019 21:41:28 +0100 Subject: [PATCH 1/2] Add ability to render null-rejoins in Timeline and MELS Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/TextForEvent.js | 4 ++-- src/components/views/elements/MemberEventListSummary.js | 9 +++++++-- src/i18n/strings/en_EN.json | 5 +++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/TextForEvent.js b/src/TextForEvent.js index a700fe2a3c..a10cea61ea 100644 --- a/src/TextForEvent.js +++ b/src/TextForEvent.js @@ -75,8 +75,8 @@ function textForMemberEvent(ev) { } else if (!prevContent.avatar_url && content.avatar_url) { return _t('%(senderName)s set a profile picture.', {senderName}); } else { - // suppress null rejoins - return ''; + // This is a null rejoin, it will only be visible if the Labs option is enabled + return _t("%(senderName)s made no change.", {senderName}); } } else { if (!ev.target) console.warn("Join message has no target! -- " + ev.getContent().state_key); diff --git a/src/components/views/elements/MemberEventListSummary.js b/src/components/views/elements/MemberEventListSummary.js index 0065fb208f..aacc1c7c18 100644 --- a/src/components/views/elements/MemberEventListSummary.js +++ b/src/components/views/elements/MemberEventListSummary.js @@ -1,6 +1,7 @@ /* Copyright 2016 OpenMarket Ltd Copyright 2019 The Matrix.org Foundation C.I.C. +Copyright 2019 Michael Telatynski <7t3chguy@gmail.com> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -17,7 +18,6 @@ limitations under the License. import React from 'react'; import PropTypes from 'prop-types'; -import sdk from '../../../index'; import MemberAvatar from '../avatars/MemberAvatar'; import { _t } from '../../../languageHandler'; import { formatCommaSeparatedList } from '../../../utils/FormattingUtils'; @@ -277,6 +277,11 @@ module.exports = React.createClass({ ? _t("%(severalUsers)schanged their avatar %(count)s times", { severalUsers: "", count: repeats }) : _t("%(oneUser)schanged their avatar %(count)s times", { oneUser: "", count: repeats }); break; + case "no_change": + res = (userCount > 1) + ? _t("%(severalUsers)smade no changes %(count)s times", { severalUsers: "", count: repeats }) + : _t("%(oneUser)smade no changes %(count)s times", { oneUser: "", count: repeats }); + break; } return res; @@ -321,7 +326,7 @@ module.exports = React.createClass({ return 'changed_avatar'; } // console.log("MELS ignoring duplicate membership join event"); - return null; + return 'no_change'; } else { return 'joined'; } diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 3edaaf6241..2881ca83fe 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -194,6 +194,7 @@ "%(senderName)s removed their profile picture.": "%(senderName)s removed their profile picture.", "%(senderName)s changed their profile picture.": "%(senderName)s changed their profile picture.", "%(senderName)s set a profile picture.": "%(senderName)s set a profile picture.", + "%(senderName)s made no change.": "%(senderName)s made no change.", "VoIP conference started.": "VoIP conference started.", "%(targetName)s joined the room.": "%(targetName)s joined the room.", "VoIP conference finished.": "VoIP conference finished.", @@ -1077,6 +1078,10 @@ "%(severalUsers)schanged their avatar %(count)s times|one": "%(severalUsers)schanged their avatar", "%(oneUser)schanged their avatar %(count)s times|other": "%(oneUser)schanged their avatar %(count)s times", "%(oneUser)schanged their avatar %(count)s times|one": "%(oneUser)schanged their avatar", + "%(severalUsers)smade no changes %(count)s times|other": "%(severalUsers)smade no changes %(count)s times", + "%(severalUsers)smade no changes %(count)s times|one": "%(severalUsers)smade no changes", + "%(oneUser)smade no changes %(count)s times|other": "%(oneUser)smade no changes %(count)s times", + "%(oneUser)smade no changes %(count)s times|one": "%(oneUser)smade no changes", "collapse": "collapse", "expand": "expand", "Edit message": "Edit message", From 46a8ec903eb295ed2dda75c24e4dd1000dfa573e Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 26 Jun 2019 20:22:01 +0100 Subject: [PATCH 2/2] Handle null-rejoins only if SettingsStore says so Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/TextForEvent.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/TextForEvent.js b/src/TextForEvent.js index a10cea61ea..e3c65e7d08 100644 --- a/src/TextForEvent.js +++ b/src/TextForEvent.js @@ -18,6 +18,7 @@ import CallHandler from './CallHandler'; import { _t } from './languageHandler'; import * as Roles from './Roles'; import {isValid3pidInvite} from "./RoomInvite"; +import SettingsStore from "./settings/SettingsStore"; function textForMemberEvent(ev) { // XXX: SYJS-16 "sender is sometimes null for join messages" @@ -74,9 +75,11 @@ function textForMemberEvent(ev) { return _t('%(senderName)s changed their profile picture.', {senderName}); } else if (!prevContent.avatar_url && content.avatar_url) { return _t('%(senderName)s set a profile picture.', {senderName}); - } else { + } else if (SettingsStore.getValue("showHiddenEventsInTimeline")) { // This is a null rejoin, it will only be visible if the Labs option is enabled return _t("%(senderName)s made no change.", {senderName}); + } else { + return ""; } } else { if (!ev.target) console.warn("Join message has no target! -- " + ev.getContent().state_key);