Fix Space Panel exploding with cyclic hierarchies
parent
f9eace1729
commit
272f06d57a
|
@ -51,6 +51,7 @@ interface IItemProps {
|
||||||
isNested?: boolean;
|
isNested?: boolean;
|
||||||
isPanelCollapsed?: boolean;
|
isPanelCollapsed?: boolean;
|
||||||
onExpand?: Function;
|
onExpand?: Function;
|
||||||
|
parents?: Set<string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IItemState {
|
interface IItemState {
|
||||||
|
@ -299,7 +300,8 @@ export class SpaceItem extends React.PureComponent<IItemProps, IItemState> {
|
||||||
const isNarrow = this.props.isPanelCollapsed;
|
const isNarrow = this.props.isPanelCollapsed;
|
||||||
const collapsed = this.state.collapsed || forceCollapsed;
|
const collapsed = this.state.collapsed || forceCollapsed;
|
||||||
|
|
||||||
const childSpaces = SpaceStore.instance.getChildSpaces(space.roomId);
|
const childSpaces = SpaceStore.instance.getChildSpaces(space.roomId)
|
||||||
|
.filter(s => !this.props.parents?.has(s.roomId));
|
||||||
const isActive = activeSpaces.includes(space);
|
const isActive = activeSpaces.includes(space);
|
||||||
const itemClasses = classNames({
|
const itemClasses = classNames({
|
||||||
"mx_SpaceItem": true,
|
"mx_SpaceItem": true,
|
||||||
|
@ -312,11 +314,17 @@ export class SpaceItem extends React.PureComponent<IItemProps, IItemState> {
|
||||||
mx_SpaceButton_narrow: isNarrow,
|
mx_SpaceButton_narrow: isNarrow,
|
||||||
});
|
});
|
||||||
const notificationState = SpaceStore.instance.getNotificationState(space.roomId);
|
const notificationState = SpaceStore.instance.getNotificationState(space.roomId);
|
||||||
const childItems = childSpaces && !collapsed ? <SpaceTreeLevel
|
|
||||||
spaces={childSpaces}
|
let childItems;
|
||||||
activeSpaces={activeSpaces}
|
if (childSpaces && !collapsed) {
|
||||||
isNested={true}
|
childItems = <SpaceTreeLevel
|
||||||
/> : null;
|
spaces={childSpaces}
|
||||||
|
activeSpaces={activeSpaces}
|
||||||
|
isNested={true}
|
||||||
|
parents={new Set(this.props.parents).add(this.props.space.roomId)}
|
||||||
|
/>;
|
||||||
|
}
|
||||||
|
|
||||||
let notifBadge;
|
let notifBadge;
|
||||||
if (notificationState) {
|
if (notificationState) {
|
||||||
notifBadge = <div className="mx_SpacePanel_badgeContainer">
|
notifBadge = <div className="mx_SpacePanel_badgeContainer">
|
||||||
|
@ -383,12 +391,14 @@ interface ITreeLevelProps {
|
||||||
spaces: Room[];
|
spaces: Room[];
|
||||||
activeSpaces: Room[];
|
activeSpaces: Room[];
|
||||||
isNested?: boolean;
|
isNested?: boolean;
|
||||||
|
parents: Set<string>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SpaceTreeLevel: React.FC<ITreeLevelProps> = ({
|
const SpaceTreeLevel: React.FC<ITreeLevelProps> = ({
|
||||||
spaces,
|
spaces,
|
||||||
activeSpaces,
|
activeSpaces,
|
||||||
isNested,
|
isNested,
|
||||||
|
parents,
|
||||||
}) => {
|
}) => {
|
||||||
return <ul className="mx_SpaceTreeLevel">
|
return <ul className="mx_SpaceTreeLevel">
|
||||||
{spaces.map(s => {
|
{spaces.map(s => {
|
||||||
|
@ -397,6 +407,7 @@ const SpaceTreeLevel: React.FC<ITreeLevelProps> = ({
|
||||||
activeSpaces={activeSpaces}
|
activeSpaces={activeSpaces}
|
||||||
space={s}
|
space={s}
|
||||||
isNested={isNested}
|
isNested={isNested}
|
||||||
|
parents={parents}
|
||||||
/>);
|
/>);
|
||||||
})}
|
})}
|
||||||
</ul>;
|
</ul>;
|
||||||
|
|
Loading…
Reference in New Issue