1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-08-10 19:32:25 +00:00

Merge pull request #5167 from haiwen/fix-move-tree-node-bug

Fix move tree node bug
This commit is contained in:
Daniel Pan 2022-04-11 18:12:28 +08:00 committed by GitHub
commit cd5b798eeb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -226,7 +226,7 @@ class LibContentView extends React.Component {
if (this.state.currentMode === 'column') { if (this.state.currentMode === 'column') {
if (this.state.isViewFile) { if (this.state.isViewFile) {
this.updataColumnMarkdownData(path); this.updateColumnMarkdownData(path);
} else { } else {
seafileAPI.dirMetaData(repoID, path).then((res) => { seafileAPI.dirMetaData(repoID, path).then((res) => {
if (res.data.id !== dirID) { if (res.data.id !== dirID) {
@ -277,7 +277,7 @@ class LibContentView extends React.Component {
}); });
} }
updataColumnMarkdownData = (filePath) => { updateColumnMarkdownData = (filePath) => {
let repoID = this.props.repoID; let repoID = this.props.repoID;
// update state // update state
this.setState({ this.setState({
@ -324,7 +324,7 @@ class LibContentView extends React.Component {
// list used FileTags // list used FileTags
this.updateUsedRepoTags(); this.updateUsedRepoTags();
// list draft counts and revierw counts // list draft counts and review counts
if (isDocs) { if (isDocs) {
seafileAPI.getRepoDraftCounts(repoID).then(res => { seafileAPI.getRepoDraftCounts(repoID).then(res => {
this.setState({ this.setState({
@ -366,11 +366,13 @@ class LibContentView extends React.Component {
let repoID = this.props.repoID; let repoID = this.props.repoID;
if (path === '/') { if (path === '/') {
seafileAPI.listDir(repoID, '/').then(res => { seafileAPI.listDir(repoID, '/').then(res => {
const { dirent_list, user_perm } = res.data;
let tree = this.state.treeData; let tree = this.state.treeData;
this.addResponseListToNode(res.data.dirent_list, tree.root); this.addResponseListToNode(dirent_list, tree.root);
this.setState({ this.setState({
isTreeDataLoading: false, isTreeDataLoading: false,
treeData: tree treeData: tree,
userPerm: user_perm,
}); });
}).catch(() => { }).catch(() => {
this.setState({isTreeDataLoading: false}); this.setState({isTreeDataLoading: false});
@ -1454,7 +1456,7 @@ class LibContentView extends React.Component {
path = Utils.getDirName(path); path = Utils.getDirName(path);
} }
seafileAPI.listDir(repoID, path, {with_parents: true}).then(res => { seafileAPI.listDir(repoID, path, {with_parents: true}).then(res => {
let direntList = res.data.dirent_list; const { dirent_list: direntList, user_perm } = res.data;
let results = {}; let results = {};
for (let i = 0; i < direntList.length; i++) { for (let i = 0; i < direntList.length; i++) {
let object = direntList[i]; let object = direntList[i];
@ -1473,7 +1475,8 @@ class LibContentView extends React.Component {
} }
this.setState({ this.setState({
isTreeDataLoading: false, isTreeDataLoading: false,
treeData: tree treeData: tree,
userPerm: user_perm,
}); });
}).catch(() => { }).catch(() => {
this.setState({isLoadFailed: true}); this.setState({isLoadFailed: true});