Improve roomlist code
Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
parent
a76dcb289a
commit
cf58a4376e
1 changed files with 7 additions and 5 deletions
|
@ -43,13 +43,15 @@ class RoomList extends EventEmitter {
|
||||||
|
|
||||||
getSpaceChildren(roomId) {
|
getSpaceChildren(roomId) {
|
||||||
const space = this.matrixClient.getRoom(roomId);
|
const space = this.matrixClient.getRoom(roomId);
|
||||||
|
if (space === null) return null;
|
||||||
const mSpaceChild = space?.currentState.getStateEvents('m.space.child');
|
const mSpaceChild = space?.currentState.getStateEvents('m.space.child');
|
||||||
const children = mSpaceChild?.map((mEvent) => {
|
|
||||||
|
const children = [];
|
||||||
|
mSpaceChild.forEach((mEvent) => {
|
||||||
const childId = mEvent.event.state_key;
|
const childId = mEvent.event.state_key;
|
||||||
if (isMEventSpaceChild(mEvent)) return childId;
|
if (isMEventSpaceChild(mEvent)) children.push(childId);
|
||||||
return null;
|
|
||||||
});
|
});
|
||||||
return children?.filter((childId) => childId !== null);
|
return children;
|
||||||
}
|
}
|
||||||
|
|
||||||
getCategorizedSpaces(spaceIds) {
|
getCategorizedSpaces(spaceIds) {
|
||||||
|
@ -69,7 +71,7 @@ class RoomList extends EventEmitter {
|
||||||
else mappedChild.add(childId);
|
else mappedChild.add(childId);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
spaceIds.map(categorizeSpace);
|
spaceIds.forEach(categorizeSpace);
|
||||||
|
|
||||||
return categorized;
|
return categorized;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue