Prevent unnecessary calc in home roomlist
Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
parent
fe18611b4b
commit
211fd19031
2 changed files with 13 additions and 7 deletions
|
@ -15,9 +15,7 @@ const drawerPostie = new Postie();
|
||||||
function Home({ spaceId }) {
|
function Home({ spaceId }) {
|
||||||
const mx = initMatrix.matrixClient;
|
const mx = initMatrix.matrixClient;
|
||||||
const { roomList, notifications, accountData } = initMatrix;
|
const { roomList, notifications, accountData } = initMatrix;
|
||||||
const {
|
const { spaces, rooms, directs } = roomList;
|
||||||
spaces, rooms, directs, roomIdToParents,
|
|
||||||
} = roomList;
|
|
||||||
useCategorizedSpaces();
|
useCategorizedSpaces();
|
||||||
const isCategorized = accountData.categorizedSpaces.has(spaceId);
|
const isCategorized = accountData.categorizedSpaces.has(spaceId);
|
||||||
|
|
||||||
|
@ -26,14 +24,14 @@ function Home({ spaceId }) {
|
||||||
let roomIds = [];
|
let roomIds = [];
|
||||||
let directIds = [];
|
let directIds = [];
|
||||||
|
|
||||||
|
if (spaceId) {
|
||||||
const spaceChildIds = roomList.getSpaceChildren(spaceId);
|
const spaceChildIds = roomList.getSpaceChildren(spaceId);
|
||||||
if (spaceChildIds) {
|
|
||||||
spaceIds = spaceChildIds.filter((roomId) => spaces.has(roomId));
|
spaceIds = spaceChildIds.filter((roomId) => spaces.has(roomId));
|
||||||
roomIds = spaceChildIds.filter((roomId) => rooms.has(roomId));
|
roomIds = spaceChildIds.filter((roomId) => rooms.has(roomId));
|
||||||
directIds = spaceChildIds.filter((roomId) => directs.has(roomId));
|
directIds = spaceChildIds.filter((roomId) => directs.has(roomId));
|
||||||
} else {
|
} else {
|
||||||
spaceIds = [...spaces].filter((roomId) => !roomIdToParents.has(roomId));
|
spaceIds = roomList.getOrphanSpaces();
|
||||||
roomIds = [...rooms].filter((roomId) => !roomIdToParents.has(roomId));
|
roomIds = roomList.getOrphanRooms();
|
||||||
}
|
}
|
||||||
|
|
||||||
spaceIds.sort(AtoZ);
|
spaceIds.sort(AtoZ);
|
||||||
|
|
|
@ -36,6 +36,14 @@ class RoomList extends EventEmitter {
|
||||||
return !this.roomIdToParents.has(roomId);
|
return !this.roomIdToParents.has(roomId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getOrphanSpaces() {
|
||||||
|
return [...this.spaces].filter((roomId) => !this.roomIdToParents.has(roomId));
|
||||||
|
}
|
||||||
|
|
||||||
|
getOrphanRooms() {
|
||||||
|
return [...this.rooms].filter((roomId) => !this.roomIdToParents.has(roomId));
|
||||||
|
}
|
||||||
|
|
||||||
getOrphans() {
|
getOrphans() {
|
||||||
const rooms = [...this.spaces].concat([...this.rooms]);
|
const rooms = [...this.spaces].concat([...this.rooms]);
|
||||||
return rooms.filter((roomId) => !this.roomIdToParents.has(roomId));
|
return rooms.filter((roomId) => !this.roomIdToParents.has(roomId));
|
||||||
|
|
Loading…
Reference in a new issue