Move expand-on-filter into the sublist
It's a bit more complicated this way, but helps reduce some of the latency involved in remounting the entire room list.pull/21833/head
parent
c6033b9410
commit
517c93a7d5
|
@ -321,7 +321,6 @@ export default class RoomList extends React.PureComponent<IProps, IState> {
|
||||||
isMinimized={this.props.isMinimized}
|
isMinimized={this.props.isMinimized}
|
||||||
onResize={this.props.onResize}
|
onResize={this.props.onResize}
|
||||||
extraBadTilesThatShouldntExist={extraTiles}
|
extraBadTilesThatShouldntExist={extraTiles}
|
||||||
isFiltered={!!RoomListStore.instance.getFirstNameFilterCondition()}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,6 @@ interface IProps {
|
||||||
isMinimized: boolean;
|
isMinimized: boolean;
|
||||||
tagId: TagID;
|
tagId: TagID;
|
||||||
onResize: () => void;
|
onResize: () => void;
|
||||||
isFiltered: boolean;
|
|
||||||
|
|
||||||
// TODO: Don't use this. It's for community invites, and community invites shouldn't be here.
|
// TODO: Don't use this. It's for community invites, and community invites shouldn't be here.
|
||||||
// You should feel bad if you use this.
|
// You should feel bad if you use this.
|
||||||
|
@ -102,17 +101,19 @@ export default class RoomSublist extends React.Component<IProps, IState> {
|
||||||
private dispatcherRef: string;
|
private dispatcherRef: string;
|
||||||
private layout: ListLayout;
|
private layout: ListLayout;
|
||||||
private heightAtStart: number;
|
private heightAtStart: number;
|
||||||
|
private isBeingFiltered: boolean;
|
||||||
|
|
||||||
constructor(props: IProps) {
|
constructor(props: IProps) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
this.layout = RoomListLayoutStore.instance.getLayoutFor(this.props.tagId);
|
this.layout = RoomListLayoutStore.instance.getLayoutFor(this.props.tagId);
|
||||||
this.heightAtStart = 0;
|
this.heightAtStart = 0;
|
||||||
|
this.isBeingFiltered = !!RoomListStore.instance.getFirstNameFilterCondition();
|
||||||
this.state = {
|
this.state = {
|
||||||
notificationState: RoomNotificationStateStore.instance.getListState(this.props.tagId),
|
notificationState: RoomNotificationStateStore.instance.getListState(this.props.tagId),
|
||||||
contextMenuPosition: null,
|
contextMenuPosition: null,
|
||||||
isResizing: false,
|
isResizing: false,
|
||||||
isExpanded: this.props.isFiltered ? this.props.isFiltered : !this.layout.isCollapsed,
|
isExpanded: this.isBeingFiltered ? this.isBeingFiltered : !this.layout.isCollapsed,
|
||||||
height: 0, // to be fixed in a moment, we need `rooms` to calculate this.
|
height: 0, // to be fixed in a moment, we need `rooms` to calculate this.
|
||||||
rooms: RoomListStore.instance.orderedLists[this.props.tagId] || [],
|
rooms: RoomListStore.instance.orderedLists[this.props.tagId] || [],
|
||||||
};
|
};
|
||||||
|
@ -173,13 +174,6 @@ export default class RoomSublist extends React.Component<IProps, IState> {
|
||||||
|
|
||||||
public componentDidUpdate(prevProps: Readonly<IProps>, prevState: Readonly<IState>) {
|
public componentDidUpdate(prevProps: Readonly<IProps>, prevState: Readonly<IState>) {
|
||||||
this.state.notificationState.setRooms(this.state.rooms);
|
this.state.notificationState.setRooms(this.state.rooms);
|
||||||
if (prevProps.isFiltered !== this.props.isFiltered) {
|
|
||||||
if (this.props.isFiltered) {
|
|
||||||
this.setState({isExpanded: true});
|
|
||||||
} else {
|
|
||||||
this.setState({isExpanded: !this.layout.isCollapsed});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const prevExtraTiles = prevState.filteredExtraTiles || prevProps.extraBadTilesThatShouldntExist;
|
const prevExtraTiles = prevState.filteredExtraTiles || prevProps.extraBadTilesThatShouldntExist;
|
||||||
// as the rooms can come in one by one we need to reevaluate
|
// as the rooms can come in one by one we need to reevaluate
|
||||||
// the amount of available rooms to cap the amount of requested visible rooms by the layout
|
// the amount of available rooms to cap the amount of requested visible rooms by the layout
|
||||||
|
@ -269,6 +263,16 @@ export default class RoomSublist extends React.Component<IProps, IState> {
|
||||||
stateUpdates.rooms = newRooms;
|
stateUpdates.rooms = newRooms;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const isStillBeingFiltered = !!RoomListStore.instance.getFirstNameFilterCondition();
|
||||||
|
if (isStillBeingFiltered !== this.isBeingFiltered) {
|
||||||
|
this.isBeingFiltered = isStillBeingFiltered;
|
||||||
|
if (isStillBeingFiltered) {
|
||||||
|
stateUpdates.isExpanded = true;
|
||||||
|
} else {
|
||||||
|
stateUpdates.isExpanded = !this.layout.isCollapsed;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (Object.keys(stateUpdates).length > 0) {
|
if (Object.keys(stateUpdates).length > 0) {
|
||||||
this.setState(stateUpdates);
|
this.setState(stateUpdates);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue