mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-05 00:43:53 +00:00
Dir view mode bug repair (#2988)
* repair history go back bug * repair switch mode bug * add Comment
This commit is contained in:
@@ -78,6 +78,7 @@ class LibContentView extends React.Component {
|
|||||||
|
|
||||||
window.onpopstate = this.onpopstate;
|
window.onpopstate = this.onpopstate;
|
||||||
this.lastModifyTime = new Date();
|
this.lastModifyTime = new Date();
|
||||||
|
this.isNeedUpdateHistoryState = true; // Load, refresh page, switch mode for the first time, no need to set historyState
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillMount() {
|
componentWillMount() {
|
||||||
@@ -122,6 +123,8 @@ class LibContentView extends React.Component {
|
|||||||
let path = location.slice(location.indexOf(repoID) + repoID.length + 1); // get the string after repoID
|
let path = location.slice(location.indexOf(repoID) + repoID.length + 1); // get the string after repoID
|
||||||
path = path.slice(path.indexOf('/')); // get current path
|
path = path.slice(path.indexOf('/')); // get current path
|
||||||
|
|
||||||
|
this.isNeedUpdateHistoryState = false;
|
||||||
|
|
||||||
this.setState({path: path});
|
this.setState({path: path});
|
||||||
|
|
||||||
if (!res.data.lib_need_decrypt) {
|
if (!res.data.lib_need_decrypt) {
|
||||||
@@ -286,8 +289,12 @@ class LibContentView extends React.Component {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// update data
|
// update data
|
||||||
this.loadDirentList(repoID, path);
|
this.loadDirentList(path);
|
||||||
|
|
||||||
|
if (!this.isNeedUpdateHistoryState) {
|
||||||
|
this.isNeedUpdateHistoryState = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
// update location
|
// update location
|
||||||
let repoInfo = this.state.currentRepoInfo;
|
let repoInfo = this.state.currentRepoInfo;
|
||||||
let url = siteRoot + 'library/' + repoID + '/' + encodeURIComponent(repoInfo.repo_name) + Utils.encodePath(path);
|
let url = siteRoot + 'library/' + repoID + '/' + encodeURIComponent(repoInfo.repo_name) + Utils.encodePath(path);
|
||||||
@@ -338,7 +345,8 @@ class LibContentView extends React.Component {
|
|||||||
window.history.pushState({url: url, path: filePath}, filePath, url);
|
window.history.pushState({url: url, path: filePath}, filePath, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
loadDirentList = (repoID, path) => {
|
loadDirentList = (path) => {
|
||||||
|
let repoID = this.props.repoID
|
||||||
seafileAPI.listDir(repoID, path, {'with_thumbnail': true}).then(res => {
|
seafileAPI.listDir(repoID, path, {'with_thumbnail': true}).then(res => {
|
||||||
let direntList = [];
|
let direntList = [];
|
||||||
let markdownItem = null;
|
let markdownItem = null;
|
||||||
@@ -522,7 +530,7 @@ class LibContentView extends React.Component {
|
|||||||
if (mode === 'column') {
|
if (mode === 'column') {
|
||||||
this.loadSidePanel(this.state.path);
|
this.loadSidePanel(this.state.path);
|
||||||
}
|
}
|
||||||
|
this.isNeedUpdateHistoryState = false;
|
||||||
this.setState({currentMode: mode});
|
this.setState({currentMode: mode});
|
||||||
this.showDir(path);
|
this.showDir(path);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user