Show error when searching public rooms fails (#11378)
* Show error when searching public rooms fails * Fix types * Improve test coverage * Improve coverage
This commit is contained in:
parent
b5bfc5be21
commit
2b17fc3221
4 changed files with 63 additions and 13 deletions
|
@ -311,6 +311,7 @@ const SpotlightDialog: React.FC<IProps> = ({ initialText = "", initialFilter = n
|
|||
config,
|
||||
setConfig,
|
||||
search: searchPublicRooms,
|
||||
error: publicRoomsError,
|
||||
} = usePublicRoomDirectory();
|
||||
const [showRooms, setShowRooms] = useState(true);
|
||||
const [showSpaces, setShowSpaces] = useState(false);
|
||||
|
@ -757,6 +758,23 @@ const SpotlightDialog: React.FC<IProps> = ({ initialText = "", initialFilter = n
|
|||
|
||||
let publicRoomsSection: JSX.Element | undefined;
|
||||
if (filter === Filter.PublicRooms) {
|
||||
let content: JSX.Element | JSX.Element[];
|
||||
if (!showRooms && !showSpaces) {
|
||||
content = (
|
||||
<div className="mx_SpotlightDialog_otherSearches_messageSearchText">
|
||||
{_t("You cannot search for rooms that are neither a room nor a space")}
|
||||
</div>
|
||||
);
|
||||
} else if (publicRoomsError) {
|
||||
content = (
|
||||
<div className="mx_SpotlightDialog_otherSearches_messageSearchText">
|
||||
{_t("Failed to query public rooms")}
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
content = results[Section.PublicRooms].slice(0, SECTION_LIMIT).map(resultMapper);
|
||||
}
|
||||
|
||||
publicRoomsSection = (
|
||||
<div
|
||||
className="mx_SpotlightDialog_section mx_SpotlightDialog_results"
|
||||
|
@ -783,16 +801,7 @@ const SpotlightDialog: React.FC<IProps> = ({ initialText = "", initialFilter = n
|
|||
<NetworkDropdown protocols={protocols} config={config ?? null} setConfig={setConfig} />
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
{" "}
|
||||
{showRooms || showSpaces ? (
|
||||
results[Section.PublicRooms].slice(0, SECTION_LIMIT).map(resultMapper)
|
||||
) : (
|
||||
<div className="mx_SpotlightDialog_otherSearches_messageSearchText">
|
||||
{_t("You cannot search for rooms that are neither a room nor a space")}
|
||||
</div>
|
||||
)}{" "}
|
||||
</div>
|
||||
<div>{content}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue