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

In People & Favourites metaspaces always show all rooms #7288

Merged
merged 1 commit into from
Dec 6, 2021
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
9 changes: 9 additions & 0 deletions src/components/views/rooms/RoomList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,14 @@ export default class RoomList extends React.PureComponent<IProps, IState> {
alwaysVisible = false;
}

let forceExpanded = false;
if (
(this.props.activeSpace === MetaSpace.Favourites && orderedTagId === DefaultTagID.Favourite) ||
(this.props.activeSpace === MetaSpace.People && orderedTagId === DefaultTagID.DM)
) {
forceExpanded = true;
}

// The cost of mounting/unmounting this component offsets the cost
// of keeping it in the DOM and hiding it when it is not required
return <RoomSublist
Expand All @@ -631,6 +639,7 @@ export default class RoomList extends React.PureComponent<IProps, IState> {
resizeNotifier={this.props.resizeNotifier}
alwaysVisible={alwaysVisible}
onListCollapse={this.props.onListCollapse}
forceExpanded={forceExpanded}
/>;
});
}
Expand Down
20 changes: 16 additions & 4 deletions src/components/views/rooms/RoomSublist.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ interface IProps {
tagId: TagID;
showSkeleton?: boolean;
alwaysVisible?: boolean;
forceExpanded?: boolean;
resizeNotifier: ResizeNotifier;
extraTiles?: ReactComponentElement<typeof ExtraTile>[];
onListCollapse?: (isExpanded: boolean) => void;
Expand Down Expand Up @@ -460,6 +461,7 @@ export default class RoomSublist extends React.Component<IProps, IState> {
};

private toggleCollapsed = () => {
if (this.props.forceExpanded) return;
this.layout.isCollapsed = this.state.isExpanded;
this.setState({ isExpanded: !this.layout.isCollapsed });
if (this.props.onListCollapse) {
Expand Down Expand Up @@ -508,15 +510,19 @@ export default class RoomSublist extends React.Component<IProps, IState> {
};

private renderVisibleTiles(): React.ReactElement[] {
if (!this.state.isExpanded) {
if (!this.state.isExpanded && !this.props.forceExpanded) {
// don't waste time on rendering
return [];
}

const tiles: React.ReactElement[] = [];

if (this.state.rooms) {
const visibleRooms = this.state.rooms.slice(0, this.numVisibleTiles);
let visibleRooms = this.state.rooms;
if (!this.props.forceExpanded) {
visibleRooms = visibleRooms.slice(0, this.numVisibleTiles);
}

for (const room of visibleRooms) {
tiles.push(<RoomTile
room={room}
Expand All @@ -537,7 +543,7 @@ export default class RoomSublist extends React.Component<IProps, IState> {
// to avoid spending cycles on slicing. It's generally fine to do this though
// as users are unlikely to have more than a handful of tiles when the extra
// tiles are used.
if (tiles.length > this.numVisibleTiles) {
if (tiles.length > this.numVisibleTiles && !this.props.forceExpanded) {
return tiles.slice(0, this.numVisibleTiles);
}

Expand Down Expand Up @@ -731,7 +737,13 @@ export default class RoomSublist extends React.Component<IProps, IState> {
});

let content = null;
if (visibleTiles.length > 0) {
if (visibleTiles.length > 0 && this.props.forceExpanded) {
content = <div className="mx_RoomSublist_resizeBox">
<div className="mx_RoomSublist_tiles" ref={this.tilesRef}>
{ visibleTiles }
</div>
</div>;
} else if (visibleTiles.length > 0) {
const layout = this.layout; // to shorten calls

const minTiles = Math.min(layout.minVisibleTiles, this.numTiles);
Expand Down