diff --git a/src/components/views/rooms/RoomList.tsx b/src/components/views/rooms/RoomList.tsx index 57c3145d47..26549cf193 100644 --- a/src/components/views/rooms/RoomList.tsx +++ b/src/components/views/rooms/RoomList.tsx @@ -501,56 +501,48 @@ export default class RoomList extends React.PureComponent { } private renderSublists(): React.ReactElement[] { - const components: React.ReactElement[] = []; - - const tagOrder = TAG_ORDER.reduce((p, c) => { - if (c === CUSTOM_TAGS_BEFORE_TAG) { - const customTags = Object.keys(this.state.sublists) - .filter(t => isCustomTag(t)); - p.push(...customTags); - } - p.push(c); - return p; - }, [] as TagID[]); - // show a skeleton UI if the user is in no rooms and they are not filtering const showSkeleton = !this.state.isNameFiltering && Object.values(RoomListStore.instance.unfilteredLists).every(list => !list?.length); - for (const orderedTagId of tagOrder) { - let extraTiles = null; - if (orderedTagId === DefaultTagID.Invite) { - extraTiles = this.renderCommunityInvites(); - } else if (orderedTagId === DefaultTagID.Suggested) { - extraTiles = this.renderSuggestedRooms(); + return TAG_ORDER.reduce((tags, tagId) => { + if (tagId === CUSTOM_TAGS_BEFORE_TAG) { + const customTags = Object.keys(this.state.sublists) + .filter(tagId => isCustomTag(tagId)); + tags.push(...customTags); } + tags.push(tagId); + return tags; + }, [] as TagID[]) + .map(orderedTagId => { + let extraTiles = null; + if (orderedTagId === DefaultTagID.Invite) { + extraTiles = this.renderCommunityInvites(); + } else if (orderedTagId === DefaultTagID.Suggested) { + extraTiles = this.renderSuggestedRooms(); + } - const aesthetics: ITagAesthetics = isCustomTag(orderedTagId) - ? customTagAesthetics(orderedTagId) - : this.tagAesthetics[orderedTagId]; - if (!aesthetics) throw new Error(`Tag ${orderedTagId} does not have aesthetics`); + const aesthetics: ITagAesthetics = isCustomTag(orderedTagId) + ? customTagAesthetics(orderedTagId) + : this.tagAesthetics[orderedTagId]; + if (!aesthetics) throw new Error(`Tag ${orderedTagId} does not have aesthetics`); - // The cost of mounting/unmounting this component all the time - // offsets the memory cost of keeping it at all time and hiding - // it when no results are found - components.push(); - } - - return components; + return + }); } public render() {