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

Commit

Permalink
In People & Favourites metaspaces always show all rooms (#7288)
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy authored Dec 6, 2021
1 parent 336f159 commit baa17e4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
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

0 comments on commit baa17e4

Please sign in to comment.