Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Update MSC3827 implementation to not change the default behaviour #8936

Merged
merged 3 commits into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,9 @@ function refIsForRecentlyViewed(ref: RefObject<HTMLElement>): boolean {
return ref.current?.id?.startsWith("mx_SpotlightDialog_button_recentlyViewed_") === true;
}

function getRoomTypes(showRooms: boolean, showSpaces: boolean): Set<RoomType | null> | null {
function getRoomTypes(showRooms: boolean, showSpaces: boolean): Set<RoomType | null> {
const roomTypes = new Set<RoomType | null>();

// This is what servers not implementing MSC3827 are expecting
if (showRooms && !showSpaces) return null;

if (showRooms) roomTypes.add(null);
if (showSpaces) roomTypes.add(RoomType.Space);

Expand Down
4 changes: 3 additions & 1 deletion src/hooks/usePublicRoomDirectory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ export const usePublicRoomDirectory = () => {
if (query || roomTypes) {
opts.filter = {
"generic_search_term": query,
"org.matrix.msc3827.room_types": roomTypes ? Array.from<RoomType | null>(roomTypes) : null,
"org.matrix.msc3827.room_types": await MatrixClientPeg.get().doesServerSupportUnstableFeature(
"org.matrix.msc3827",
) ? Array.from<RoomType | null>(roomTypes) : null,
};
}

Expand Down