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

Commit baa17e4

Browse files
authored
In People & Favourites metaspaces always show all rooms (#7288)
1 parent 336f159 commit baa17e4

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

src/components/views/rooms/RoomList.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,14 @@ export default class RoomList extends React.PureComponent<IProps, IState> {
616616
alwaysVisible = false;
617617
}
618618

619+
let forceExpanded = false;
620+
if (
621+
(this.props.activeSpace === MetaSpace.Favourites && orderedTagId === DefaultTagID.Favourite) ||
622+
(this.props.activeSpace === MetaSpace.People && orderedTagId === DefaultTagID.DM)
623+
) {
624+
forceExpanded = true;
625+
}
626+
619627
// The cost of mounting/unmounting this component offsets the cost
620628
// of keeping it in the DOM and hiding it when it is not required
621629
return <RoomSublist
@@ -631,6 +639,7 @@ export default class RoomList extends React.PureComponent<IProps, IState> {
631639
resizeNotifier={this.props.resizeNotifier}
632640
alwaysVisible={alwaysVisible}
633641
onListCollapse={this.props.onListCollapse}
642+
forceExpanded={forceExpanded}
634643
/>;
635644
});
636645
}

src/components/views/rooms/RoomSublist.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ interface IProps {
7979
tagId: TagID;
8080
showSkeleton?: boolean;
8181
alwaysVisible?: boolean;
82+
forceExpanded?: boolean;
8283
resizeNotifier: ResizeNotifier;
8384
extraTiles?: ReactComponentElement<typeof ExtraTile>[];
8485
onListCollapse?: (isExpanded: boolean) => void;
@@ -460,6 +461,7 @@ export default class RoomSublist extends React.Component<IProps, IState> {
460461
};
461462

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

510512
private renderVisibleTiles(): React.ReactElement[] {
511-
if (!this.state.isExpanded) {
513+
if (!this.state.isExpanded && !this.props.forceExpanded) {
512514
// don't waste time on rendering
513515
return [];
514516
}
515517

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

518520
if (this.state.rooms) {
519-
const visibleRooms = this.state.rooms.slice(0, this.numVisibleTiles);
521+
let visibleRooms = this.state.rooms;
522+
if (!this.props.forceExpanded) {
523+
visibleRooms = visibleRooms.slice(0, this.numVisibleTiles);
524+
}
525+
520526
for (const room of visibleRooms) {
521527
tiles.push(<RoomTile
522528
room={room}
@@ -537,7 +543,7 @@ export default class RoomSublist extends React.Component<IProps, IState> {
537543
// to avoid spending cycles on slicing. It's generally fine to do this though
538544
// as users are unlikely to have more than a handful of tiles when the extra
539545
// tiles are used.
540-
if (tiles.length > this.numVisibleTiles) {
546+
if (tiles.length > this.numVisibleTiles && !this.props.forceExpanded) {
541547
return tiles.slice(0, this.numVisibleTiles);
542548
}
543549

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

733739
let content = null;
734-
if (visibleTiles.length > 0) {
740+
if (visibleTiles.length > 0 && this.props.forceExpanded) {
741+
content = <div className="mx_RoomSublist_resizeBox">
742+
<div className="mx_RoomSublist_tiles" ref={this.tilesRef}>
743+
{ visibleTiles }
744+
</div>
745+
</div>;
746+
} else if (visibleTiles.length > 0) {
735747
const layout = this.layout; // to shorten calls
736748

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

0 commit comments

Comments
 (0)