mirror of
https://github.com/Novaloop-AG/healthchat-web.git
synced 2026-11-10 01:01:45 +00:00
update initially shown amount of tiles on component update
as rooms aren't all available at ctor time
This commit is contained in:
@@ -142,7 +142,11 @@ export default class RoomSublist2 extends React.Component<IProps, IState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private get numTiles(): number {
|
private get numTiles(): number {
|
||||||
return (this.props.rooms || []).length + (this.props.extraBadTilesThatShouldntExist || []).length;
|
return RoomSublist2.calcNumTiles(this.props);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static calcNumTiles(props) {
|
||||||
|
return (props.rooms || []).length + (props.extraBadTilesThatShouldntExist || []).length;
|
||||||
}
|
}
|
||||||
|
|
||||||
private get numVisibleTiles(): number {
|
private get numVisibleTiles(): number {
|
||||||
@@ -150,8 +154,13 @@ export default class RoomSublist2 extends React.Component<IProps, IState> {
|
|||||||
return Math.min(nVisible, this.numTiles);
|
return Math.min(nVisible, this.numTiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
public componentDidUpdate() {
|
public componentDidUpdate(prevProps) {
|
||||||
this.state.notificationState.setRooms(this.props.rooms);
|
this.state.notificationState.setRooms(this.props.rooms);
|
||||||
|
// 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
|
||||||
|
if (RoomSublist2.calcNumTiles(prevProps) !== this.numTiles) {
|
||||||
|
this.setState({height: this.calculateInitialHeight()});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public componentWillUnmount() {
|
public componentWillUnmount() {
|
||||||
|
|||||||
Reference in New Issue
Block a user