From 7d032bb6840b93156c308b14a631c3c2f9e466fd Mon Sep 17 00:00:00 2001 From: Gero Gerke Date: Thu, 30 Sep 2021 17:24:28 +0200 Subject: [PATCH 1/2] Improve message when there are no public rooms on a server --- src/app/organisms/public-rooms/PublicRooms.jsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/app/organisms/public-rooms/PublicRooms.jsx b/src/app/organisms/public-rooms/PublicRooms.jsx index b8f9244..b7d2dbb 100644 --- a/src/app/organisms/public-rooms/PublicRooms.jsx +++ b/src/app/organisms/public-rooms/PublicRooms.jsx @@ -137,7 +137,7 @@ function PublicRooms({ isOpen, searchTerm, onRequestClose }) { updateNextBatch(result.next_batch); updateIsSearching(false); updateIsViewMore(false); - if (totalRooms.length === 0) { + if (totalRooms.length === 0 && inputRoomName !== '') { updateSearchQuery({ error: `No result found for "${inputRoomName}" on ${inputHs}`, alias: isInputAlias ? inputRoomName : null, @@ -241,12 +241,20 @@ function PublicRooms({ isOpen, searchTerm, onRequestClose }) { ) } { - typeof searchQuery.name !== 'undefined' && !isSearching && ( + typeof searchQuery.name !== 'undefined' && !isSearching && publicRooms.length !== 0 && ( searchQuery.name === '' ? {`Public rooms on ${searchQuery.homeserver}.`} : {`Search result for "${searchQuery.name}" on ${searchQuery.homeserver}.`} ) } + { + typeof searchQuery.name !== 'undefined' && !isSearching && publicRooms.length === 0 + && ( +
+ {`There are no public rooms on ${searchQuery.homeserver}.`} +
+ ) + } { searchQuery.error && ( <> {searchQuery.error} From 8e5a5baf52d5329c5a7e97633c1707cb72b4aa79 Mon Sep 17 00:00:00 2001 From: Ajay Bura Date: Sun, 3 Oct 2021 09:53:54 +0530 Subject: [PATCH 2/2] Better error handling when server room list is private Signed-off-by: Ajay Bura --- .../organisms/public-rooms/PublicRooms.jsx | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/app/organisms/public-rooms/PublicRooms.jsx b/src/app/organisms/public-rooms/PublicRooms.jsx index b7d2dbb..2340129 100644 --- a/src/app/organisms/public-rooms/PublicRooms.jsx +++ b/src/app/organisms/public-rooms/PublicRooms.jsx @@ -137,16 +137,22 @@ function PublicRooms({ isOpen, searchTerm, onRequestClose }) { updateNextBatch(result.next_batch); updateIsSearching(false); updateIsViewMore(false); - if (totalRooms.length === 0 && inputRoomName !== '') { + if (totalRooms.length === 0) { updateSearchQuery({ - error: `No result found for "${inputRoomName}" on ${inputHs}`, + error: inputRoomName === '' + ? `No public rooms on ${inputHs}` + : `No result found for "${inputRoomName}" on ${inputHs}`, alias: isInputAlias ? inputRoomName : null, }); } } catch (e) { updatePublicRooms([]); + let err = 'Something went wrong!'; + if (e?.httpStatus >= 400 && e?.httpStatus < 500) { + err = e.message; + } updateSearchQuery({ - error: 'Something went wrong!', + error: err, alias: isInputAlias ? inputRoomName : null, }); updateIsSearching(false); @@ -241,20 +247,12 @@ function PublicRooms({ isOpen, searchTerm, onRequestClose }) { ) } { - typeof searchQuery.name !== 'undefined' && !isSearching && publicRooms.length !== 0 && ( + typeof searchQuery.name !== 'undefined' && !isSearching && ( searchQuery.name === '' ? {`Public rooms on ${searchQuery.homeserver}.`} : {`Search result for "${searchQuery.name}" on ${searchQuery.homeserver}.`} ) } - { - typeof searchQuery.name !== 'undefined' && !isSearching && publicRooms.length === 0 - && ( -
- {`There are no public rooms on ${searchQuery.homeserver}.`} -
- ) - } { searchQuery.error && ( <> {searchQuery.error}