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

Fix move dirent in tree view not delete old dirent (#7908)

* 01 optimise codes

* 02 move new dirent after delete old dirent

03 fix right panel dirent list refresh
This commit is contained in:
Michael An
2025-06-10 11:23:26 +08:00
committed by GitHub
parent 8cc63be9fd
commit c04ae13a81
2 changed files with 25 additions and 16 deletions

View File

@@ -1323,17 +1323,24 @@ class LibContentView extends React.Component {
});
}
if (this.state.isTreePanelShown) {
this.deleteTreeNode(direntPath);
}
// 1. move to current repo
// 2. tow columns mode need update left tree
if (repoID === targetRepo.repo_id && this.state.isTreePanelShown) {
this.updateMoveCopyTreeNode(moveToDirentPath);
}
const updateAfterMove = () => {
if (repoID === targetRepo.repo_id && this.state.isTreePanelShown) {
this.updateMoveCopyTreeNode(moveToDirentPath);
}
this.moveDirent(direntPath, moveToDirentPath);
this.setState({ path: moveToDirentPath });
if (this.state.path !== moveToDirentPath) {
this.loadDirentList(moveToDirentPath);
}
};
this.moveDirent(direntPath, moveToDirentPath);
if (this.state.isTreePanelShown) {
this.deleteTreeNode(direntPath, updateAfterMove);
} else {
updateAfterMove();
}
// show tip message if move to current repo
if (repoID === targetRepo.repo_id) {
@@ -1345,6 +1352,10 @@ class LibContentView extends React.Component {
if (byDialog) {
this.updateRecentlyUsedList(targetRepo, moveToDirentPath);
}
// update location
let repoInfo = this.state.currentRepoInfo;
let url = siteRoot + 'library/' + repoID + '/' + encodeURIComponent(repoInfo.repo_name) + Utils.encodePath(moveToDirentPath);
window.history.pushState({ url, path: moveToDirentPath }, moveToDirentPath, url);
};
onMoveItem = (destRepo, dirent, moveToDirentPath, nodeParentPath, byDialog = false) => {
@@ -2040,9 +2051,11 @@ class LibContentView extends React.Component {
this.setState({ treeData: tree, currentNode });
};
deleteTreeNode = (path) => {
deleteTreeNode = (path, callback) => {
let tree = treeHelper.deleteNodeByPath(this.state.treeData, path);
this.setState({ treeData: tree });
this.setState({ treeData: tree }, () => {
callback && callback();
});
};
deleteTreeNodes = (paths) => {