Skip to content

πŸ“š The open-source, offline-first Notion, Obsidian & Confluence alternative. Advanced Markdown, multi-tenant teams, OIDC/SSO, and local S3 backups. Deploy in one command.

Optimize isDescendant function

Smaug67397325cf380a82
diff --git a/frontend/app/stores/nodes.store.ts b/frontend/app/stores/nodes.store.ts
index 2276fad5..603c7a48 100644
--- a/frontend/app/stores/nodes.store.ts
+++ b/frontend/app/stores/nodes.store.ts
@@ -37,9 +37,9 @@ export const useNodesStore = defineStore('nodes', {
(node: Node, descendantId: string): boolean => {
const checkDescendants = (currentNode: Node): boolean => {
const children = state.nodes.filter(d => d.parent_id === currentNode.id);
- for (const child of children) {
- if (child[0] === descendantId) return true;
- if (checkDescendants(child[1])) return true;
+ for (const child of children.values()) {
+ if (child.id === descendantId) return true;
+ if (checkDescendants(child)) return true;
}
return false;
};