From f9f87defa4bfaf108e4f946c237d18881d9e0c25 Mon Sep 17 00:00:00 2001 From: Aaron Raimist Date: Sat, 7 Mar 2020 12:36:24 -0600 Subject: [PATCH] Only show old room name if it exists --- src/TextForEvent.js | 13 +++++++++---- src/i18n/strings/en_EN.json | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/TextForEvent.js b/src/TextForEvent.js index 79083e351c..e897ec2911 100644 --- a/src/TextForEvent.js +++ b/src/TextForEvent.js @@ -127,11 +127,16 @@ function textForRoomNameEvent(ev) { if (!ev.getContent().name || ev.getContent().name.trim().length === 0) { return _t('%(senderDisplayName)s removed the room name.', {senderDisplayName}); } - debugger; - return _t('%(senderDisplayName)s changed the room name from %(oldRoomName)s to %(newRoomName)s.', { + if (ev.getPrevContent().name) { + return _t('%(senderDisplayName)s changed the room name from %(oldRoomName)s to %(newRoomName)s.', { + senderDisplayName, + oldRoomName: ev.getPrevContent().name, + newRoomName: ev.getContent().name, + }); + } + return _t('%(senderDisplayName)s changed the room name to %(roomName)s.', { senderDisplayName, - oldRoomName: ev.getPrevContent().name, - newRoomName: ev.getContent().name, + roomName: ev.getContent().name, }); } diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json index 8b4e9417bb..ca955afcc9 100644 --- a/src/i18n/strings/en_EN.json +++ b/src/i18n/strings/en_EN.json @@ -229,6 +229,7 @@ "%(senderDisplayName)s changed the topic to \"%(topic)s\".": "%(senderDisplayName)s changed the topic to \"%(topic)s\".", "%(senderDisplayName)s removed the room name.": "%(senderDisplayName)s removed the room name.", "%(senderDisplayName)s changed the room name from %(oldRoomName)s to %(newRoomName)s.": "%(senderDisplayName)s changed the room name from %(oldRoomName)s to %(newRoomName)s.", + "%(senderDisplayName)s changed the room name to %(roomName)s.": "%(senderDisplayName)s changed the room name to %(roomName)s.", "%(senderDisplayName)s upgraded this room.": "%(senderDisplayName)s upgraded this room.", "%(senderDisplayName)s made the room public to whoever knows the link.": "%(senderDisplayName)s made the room public to whoever knows the link.", "%(senderDisplayName)s made the room invite only.": "%(senderDisplayName)s made the room invite only.",