From 1153ce43c6c2af45031a4a3dbaedc37d6a408241 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Wed, 3 Apr 2019 20:38:25 +0100 Subject: [PATCH 1/3] fix NPE for rooms with redacted tombstones --- src/matrix-to.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/matrix-to.js b/src/matrix-to.js index 15979000c4..99a02dc42d 100644 --- a/src/matrix-to.js +++ b/src/matrix-to.js @@ -241,7 +241,7 @@ export function makeRoomPermalink(roomId) { // If the roomId isn't actually a room ID, don't try to list the servers. // Aliases are already routable, and don't need extra information. - if (roomId[0] !== '!') return permalinkBase; + if (!roomId || roomId[0] !== '!') return permalinkBase; const client = MatrixClientPeg.get(); const room = client.getRoom(roomId); From e98ef0d5370c31819baa4ef3b57d1bc3b60acbc2 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Wed, 3 Apr 2019 21:12:36 +0100 Subject: [PATCH 2/3] only show continues link if tombstone has a continuation --- src/components/views/rooms/MessageComposer.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/components/views/rooms/MessageComposer.js b/src/components/views/rooms/MessageComposer.js index 535d565d22..576f45a3bc 100644 --- a/src/components/views/rooms/MessageComposer.js +++ b/src/components/views/rooms/MessageComposer.js @@ -362,18 +362,22 @@ export default class MessageComposer extends React.Component { } else if (this.state.tombstone) { const replacementRoomId = this.state.tombstone.getContent()['replacement_room']; + const continuesLink = replacementRoomId ? ( + + {_t("The conversation continues here.")} + + ) : ''; + controls.push(
{_t("This room has been replaced and is no longer active.")}
- - {_t("The conversation continues here.")} - + { continuesLink }
); } else { From b9eebee13be0b87788c32070e39248316a5e6e38 Mon Sep 17 00:00:00 2001 From: Matthew Hodgson Date: Thu, 4 Apr 2019 16:53:17 +0100 Subject: [PATCH 3/3] turn NPE into a throw --- src/matrix-to.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/matrix-to.js b/src/matrix-to.js index 99a02dc42d..7223f2e33d 100644 --- a/src/matrix-to.js +++ b/src/matrix-to.js @@ -239,9 +239,13 @@ export function makeUserPermalink(userId) { export function makeRoomPermalink(roomId) { const permalinkBase = `${baseUrl}/#/${roomId}`; + if (!roomId) { + throw new Error("can't permalink a falsey roomId"); + } + // If the roomId isn't actually a room ID, don't try to list the servers. // Aliases are already routable, and don't need extra information. - if (!roomId || roomId[0] !== '!') return permalinkBase; + if (roomId[0] !== '!') return permalinkBase; const client = MatrixClientPeg.get(); const room = client.getRoom(roomId);