From 045def4566c14aa898e6e6d83b8f4461ef96aca6 Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Thu, 18 Jun 2020 22:45:42 +0100
Subject: [PATCH 1/3] hide search results from unknown rooms
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---
src/components/structures/RoomView.js | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js
index 4a0cc470d5..779db46c76 100644
--- a/src/components/structures/RoomView.js
+++ b/src/components/structures/RoomView.js
@@ -1314,6 +1314,13 @@ export default createReactClass({
const mxEv = result.context.getEvent();
const roomId = mxEv.getRoomId();
const room = this.context.getRoom(roomId);
+ if (!room) {
+ // if we do not have the room in js-sdk stores then hide it as we cannot easily show it
+ // As per the spec, an all rooms search can create this condition,
+ // it happens with Seshat but not Synapse.
+ console.log("Hiding search result from an unknown room", roomId);
+ continue;
+ }
if (!haveTileForEvent(mxEv)) {
// XXX: can this ever happen? It will make the result count
@@ -1322,13 +1329,12 @@ export default createReactClass({
}
if (this.state.searchScope === 'All') {
- if (roomId != lastRoomId) {
-
+ if (roomId !== lastRoomId) {
// XXX: if we've left the room, we might not know about
// it. We should tell the js sdk to go and find out about
// it. But that's not an issue currently, as synapse only
// returns results for rooms we're joined to.
- const roomName = room ? room.name : _t("Unknown room %(roomId)s", { roomId: roomId });
+ const roomName = room.name;
ret.push(
{ _t("Room") }: { roomName }
From eec42cff490c00c141def8d2cb04a714f79cd594 Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Thu, 18 Jun 2020 22:49:39 +0100
Subject: [PATCH 2/3] tidy up
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---
src/components/structures/RoomView.js | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js
index 779db46c76..3051a9263f 100644
--- a/src/components/structures/RoomView.js
+++ b/src/components/structures/RoomView.js
@@ -1318,6 +1318,7 @@ export default createReactClass({
// if we do not have the room in js-sdk stores then hide it as we cannot easily show it
// As per the spec, an all rooms search can create this condition,
// it happens with Seshat but not Synapse.
+ // It will make the result count not match the displayed count.
console.log("Hiding search result from an unknown room", roomId);
continue;
}
@@ -1330,14 +1331,8 @@ export default createReactClass({
if (this.state.searchScope === 'All') {
if (roomId !== lastRoomId) {
- // XXX: if we've left the room, we might not know about
- // it. We should tell the js sdk to go and find out about
- // it. But that's not an issue currently, as synapse only
- // returns results for rooms we're joined to.
- const roomName = room.name;
-
ret.push(
- { _t("Room") }: { roomName }
+ { _t("Room") }: { room.name }
);
lastRoomId = roomId;
}
From 3ac028565b531a8fd16b96d3ec7b4ef70c5c9334 Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Thu, 18 Jun 2020 22:50:10 +0100
Subject: [PATCH 3/3] i18n
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---
src/i18n/strings/en_EN.json | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/i18n/strings/en_EN.json b/src/i18n/strings/en_EN.json
index b659979fde..8a00abbde4 100644
--- a/src/i18n/strings/en_EN.json
+++ b/src/i18n/strings/en_EN.json
@@ -2038,7 +2038,6 @@
"Search failed": "Search failed",
"Server may be unavailable, overloaded, or search timed out :(": "Server may be unavailable, overloaded, or search timed out :(",
"No more results": "No more results",
- "Unknown room %(roomId)s": "Unknown room %(roomId)s",
"Room": "Room",
"Failed to reject invite": "Failed to reject invite",
"You have %(count)s unread notifications in a prior version of this room.|other": "You have %(count)s unread notifications in a prior version of this room.",