1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-05 17:02:47 +00:00

Fix/record not found (#7606)

* fix path

* fix record not found after rename node

* fix path update

* fix rename dialog display

---------

Co-authored-by: zhouwenxuan <aries@Mac.local>
This commit is contained in:
Aries
2025-03-14 10:31:04 +08:00
committed by GitHub
parent cb074ea304
commit 0c29734c5f
5 changed files with 34 additions and 63 deletions

View File

@@ -279,10 +279,7 @@ class LibContentView extends React.Component {
});
}
componentDidUpdate(prevProps, prevState) {
if (prevState.path !== this.state.path) {
this.setState({ currentDirent: null });
}
componentDidUpdate() {
this.lastModifyTime = new Date();
this.props.eventBus.dispatch(EVENT_BUS_TYPE.CURRENT_LIBRARY_CHANGED, {
repoID: this.props.repoID,
@@ -563,6 +560,7 @@ class LibContentView extends React.Component {
this.setState({
isDirentListLoading: true,
direntList: [],
path,
});
seafileAPI.listDir(repoID, path, { 'with_thumbnail': true }).then(res => {
const { dirent_list, user_perm: userPerm, dir_id: dirID } = res.data;
@@ -1083,13 +1081,11 @@ class LibContentView extends React.Component {
};
onMainNavBarClick = (nodePath) => {
// just for dir
this.resetSelected(nodePath);
if (this.state.isTreePanelShown) {
let tree = this.state.treeData.clone();
let node = tree.getNodeByPath(nodePath);
tree.expandNode(node);
this.setState({ treeData: tree, currentNode: node });
this.setState({ treeData: tree, currentNode: nodePath !== '/' ? node : null });
}
this.showDir(nodePath);
@@ -1853,6 +1849,7 @@ class LibContentView extends React.Component {
this.setState({
isTreeDataLoading: false,
treeData: tree,
currentNode: tree.getNodeByPath(path),
userPerm: user_perm,
});
}).catch(() => {
@@ -1869,6 +1866,7 @@ class LibContentView extends React.Component {
}
if (node.object.isDir()) {
this.setState({ currentNode: node, path: node.path });
let isLoaded = node.isLoaded;
if (!node.isLoaded) {
let tree = this.state.treeData.clone();
@@ -1907,10 +1905,12 @@ class LibContentView extends React.Component {
this.showDir(node.path);
} else {
if (Utils.isFileMetadata(node?.object?.type)) {
this.setState({ currentNode: null });
if (node.path !== this.state.path) {
this.showFileMetadata(node.path, node.view_id || '0000');
}
} else if (Utils.isTags(node?.object?.type)) {
this.setState({ currentNode: null });
if (node.path !== this.state.path) {
this.showTagsView(node.path, node.tag_id);
}
@@ -1956,7 +1956,9 @@ class LibContentView extends React.Component {
renameTreeNode = (path, newName) => {
let tree = treeHelper.renameNodeByPath(this.state.treeData, path, newName);
this.setState({ treeData: tree });
const newPath = Utils.joinPath(Utils.getDirName(path), newName);
const currentNode = path === this.state.currentNode?.path ? tree.getNodeByPath(newPath) : this.state.currentNode;
this.setState({ treeData: tree, currentNode });
};
deleteTreeNode = (path) => {
@@ -2192,7 +2194,7 @@ class LibContentView extends React.Component {
render() {
const { repoID } = this.props;
let { currentRepoInfo, userPerm, isCopyMoveProgressDialogShow, isDeleteFolderDialogOpen, errorMsg,
path, usedRepoTags, isDirentSelected, currentMode } = this.state;
path, usedRepoTags, isDirentSelected, currentMode, currentNode } = this.state;
if (this.state.libNeedDecrypt) {
return (
@@ -2258,6 +2260,11 @@ class LibContentView extends React.Component {
currentDirent = currentDirent.toJson();
}
let detailPath = this.state.path;
if (!currentDirent && currentMode !== METADATA_MODE && currentMode !== TAGS_MODE) {
detailPath = Utils.getDirName(this.state.path);
}
const detailDirent = currentDirent || currentNode?.object || null;
return (
<MetadataStatusProvider repoID={repoID} repoInfo={currentRepoInfo} hideMetadataView={this.hideMetadataView}>
<TagsProvider repoID={repoID} currentPath={path} repoInfo={currentRepoInfo} selectTagsView={this.onTreeNodeClick} >
@@ -2443,10 +2450,10 @@ class LibContentView extends React.Component {
}
{!isCustomPermission && this.state.isDirentDetailShow && (
<Detail
path={this.state.path}
path={detailPath}
repoID={this.props.repoID}
currentRepoInfo={{ ...this.state.currentRepoInfo }}
dirent={currentDirent}
dirent={detailDirent}
repoTags={this.state.repoTags}
fileTags={this.state.isViewFile ? this.state.fileTags : []}
onFileTagChanged={this.onFileTagChanged}