optimizations
This commit is contained in:
1 parent
056adb88b8
commit
1333ee0549
3 files changed
+14
-45
No files matched your search
@@ -107,13 +107,7 @@ export function AddExistingModal({ parentId, space, requestClose }: AddExistingM
|
||||
return true;
|
||||
}
|
||||
|
||||
let hasAncestor = false;
|
||||
parentIds.forEach((id) => {
|
||||
if (isAncestor(sourceId, id, visited)) {
|
||||
hasAncestor = true;
|
||||
}
|
||||
});
|
||||
return hasAncestor;
|
||||
return Array.from(parentIds).some((id) => isAncestor(sourceId, id, visited));
|
||||
},
|
||||
[roomIdToParents]
|
||||
);
|
||||
|
||||
@@ -235,14 +235,9 @@ export function Lobby() {
|
||||
|
||||
// As a subspace can be in multiple spaces,
|
||||
// only return true if all parent spaces are closed.
|
||||
let anyOpen = false;
|
||||
parentParentIds.forEach((id) => {
|
||||
if (!getInClosedCategories(spaceId, id, parentId)) {
|
||||
anyOpen = true;
|
||||
}
|
||||
});
|
||||
closedCategoriesCache.current.set(categoryId, !anyOpen);
|
||||
return !anyOpen;
|
||||
return !Array.from(parentParentIds).some(
|
||||
(id) => !getInClosedCategories(spaceId, id, parentId)
|
||||
);
|
||||
},
|
||||
[closedCategories, getRoom, roomToParents, spaceRooms]
|
||||
);
|
||||
@@ -261,13 +256,7 @@ export function Lobby() {
|
||||
return false;
|
||||
}
|
||||
|
||||
let allCollapsed = true;
|
||||
parentIds.forEach((id) => {
|
||||
if (!getInClosedCategories(spaceId, id, roomId)) {
|
||||
allCollapsed = false;
|
||||
}
|
||||
});
|
||||
return allCollapsed;
|
||||
return !Array.from(parentIds).some((id) => !getInClosedCategories(spaceId, id, roomId));
|
||||
};
|
||||
|
||||
const [draggingItem, setDraggingItem] = useState<HierarchyItem>();
|
||||
|
||||
@@ -453,14 +453,11 @@ export function Space() {
|
||||
|
||||
// As a subspace can be in multiple spaces,
|
||||
// only return true if all parent spaces are closed.
|
||||
let anyOpen = false;
|
||||
parentParentIds.forEach((id) => {
|
||||
if (!getInClosedCategories(spaceId, id, parentId)) {
|
||||
anyOpen = true;
|
||||
}
|
||||
});
|
||||
closedCategoriesCache.current.set(categoryId, !anyOpen);
|
||||
return !anyOpen;
|
||||
const allClosed = !Array.from(parentParentIds).some(
|
||||
(id) => !getInClosedCategories(spaceId, id, parentId)
|
||||
);
|
||||
closedCategoriesCache.current.set(categoryId, allClosed);
|
||||
return allClosed;
|
||||
},
|
||||
[closedCategories, getRoom, roomToParents, spaceRooms]
|
||||
);
|
||||
@@ -482,14 +479,7 @@ export function Space() {
|
||||
return false;
|
||||
}
|
||||
|
||||
let visible = false;
|
||||
childIds.forEach((id) => {
|
||||
if (getContainsShowRoom(id)) {
|
||||
visible = true;
|
||||
}
|
||||
});
|
||||
|
||||
return visible;
|
||||
return Array.from(childIds).some((id) => getContainsShowRoom(id));
|
||||
},
|
||||
[roomToUnread, selectedRoomId, roomToChildren]
|
||||
);
|
||||
@@ -513,13 +503,9 @@ export function Space() {
|
||||
return false;
|
||||
}
|
||||
|
||||
let allCollapsed = true;
|
||||
parentIds.forEach((id) => {
|
||||
if (!getInClosedCategories(spaceId, id, roomId)) {
|
||||
allCollapsed = false;
|
||||
}
|
||||
});
|
||||
|
||||
const allCollapsed = !Array.from(parentIds).some(
|
||||
(id) => !getInClosedCategories(spaceId, id, roomId)
|
||||
);
|
||||
ancestorsCollapsedCache.current.set(categoryId, allCollapsed);
|
||||
return allCollapsed;
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user