1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-26 15:26:19 +00:00

Optimize/tree op validation (#8157)

* optimize tree operations validation

* optimize

* optimize

---------

Co-authored-by: zhouwenxuan <aries@Mac.local>
Co-authored-by: Michael An <1822852997@qq.com>
This commit is contained in:
Aries
2025-08-21 11:17:16 +08:00
committed by GitHub
parent 7751f590da
commit 6d82b7dee4
2 changed files with 23 additions and 0 deletions

View File

@@ -2032,7 +2032,18 @@ class LibContentView extends React.Component {
}
};
isTreeReady = (path = null) => {
const { treeData, isTreeDataLoading } = this.state;
if (isTreeDataLoading || !treeData || !treeData.root) return false;
if (path) {
const node = treeData.getNodeByPath(path);
return node !== null;
}
return true;
};
addNodeToTree = (name, parentPath, type) => {
if (!this.isTreeReady(parentPath)) return;
let node = this.createTreeNode(name, type);
let tree = treeHelper.addNodeToParentByPath(this.state.treeData, node, parentPath);
this.setState({ treeData: tree });