mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-05 17:02:47 +00:00
optimized wiki page refresh code
This commit is contained in:
@@ -77,13 +77,39 @@ class Wiki extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
loadSidePanel = (initialPath) => {
|
loadSidePanel = (initialPath) => {
|
||||||
if (initialPath === this.homePath || isDir === 'None') {
|
|
||||||
|
if (initialPath === this.homePath) {
|
||||||
|
if (hasIndex) {
|
||||||
|
this.loadIndexNode();
|
||||||
|
} else {
|
||||||
|
initialPath = '/';
|
||||||
|
this.loadNodeAndParentsByPath(initialPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (initialPath !== this.homePath) {
|
||||||
|
if (isDir === 'None') {
|
||||||
|
if (hasIndex) {
|
||||||
|
this.loadIndexNode();
|
||||||
|
} else {
|
||||||
|
initialPath = '/';
|
||||||
|
this.loadNodeAndParentsByPath(initialPath);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (hasIndex) {
|
||||||
|
this.loadIndexNode();
|
||||||
|
} else {
|
||||||
|
this.loadNodeAndParentsByPath(initialPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
loadIndexNode = () => {
|
||||||
seafileAPI.listWikiDir(slug, '/').then(res => {
|
seafileAPI.listWikiDir(slug, '/').then(res => {
|
||||||
let tree = this.state.treeData;
|
let tree = this.state.treeData;
|
||||||
this.addFirstResponseListToNode(res.data.dirent_list, tree.root);
|
this.addFirstResponseListToNode(res.data.dirent_list, tree.root);
|
||||||
let indexNode = tree.getNodeByPath(this.indexPath);
|
let indexNode = tree.getNodeByPath(this.indexPath);
|
||||||
let homeNode = tree.getNodeByPath(this.homePath);
|
|
||||||
if (homeNode && indexNode) {
|
|
||||||
seafileAPI.getWikiFileContent(slug, indexNode.path).then(res => {
|
seafileAPI.getWikiFileContent(slug, indexNode.path).then(res => {
|
||||||
this.setState({
|
this.setState({
|
||||||
treeData: tree,
|
treeData: tree,
|
||||||
@@ -92,18 +118,9 @@ class Wiki extends Component {
|
|||||||
isTreeDataLoading: false,
|
isTreeDataLoading: false,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
this.setState({
|
|
||||||
treeData: tree,
|
|
||||||
isTreeDataLoading: false,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
this.setState({isLoadFailed: true});
|
this.setState({isLoadFailed: true});
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
this.loadNodeAndParentsByPath(initialPath);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
showDir = (dirPath) => {
|
showDir = (dirPath) => {
|
||||||
|
Reference in New Issue
Block a user