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

improve file history (#3564)

This commit is contained in:
王健辉
2019-05-28 18:21:47 +08:00
committed by Daniel Pan
parent e92bc848b2
commit 559cd94b7d

View File

@@ -65,12 +65,39 @@ class FileHistory extends React.Component {
}
initNewRecords(result) {
this.setState({
historyList: result.data,
currentPage: result.page,
hasMore: result.total_count > (PER_PAGE * this.state.currentPage),
isLoading: false,
});
if (result.total_count < 5) {
if (result.data.length) {
let commitID = result.data[result.data.length-1].commit_id;
seafileAPI.listOldFileHistoryRecords(historyRepoID, filePath, commitID).then((res) => {
if (!res.data) {
this.setState({isLoading: false});
throw Error('There is an error in server.');
}
this.setState({
historyList: result.data.concat(res.data.data.slice(1, res.data.data.length)),
isLoading: false,
});
});
} else {
seafileAPI.listOldFileHistoryRecords(historyRepoID, filePath).then((res) => {
if (!res.data) {
this.setState({isLoading: false});
throw Error('There is an error in server.');
}
this.setState({
historyList: res.data.data,
isLoading: false,
});
});
}
} else {
this.setState({
historyList: result.data,
currentPage: result.page,
hasMore: result.total_count > (PER_PAGE * this.state.currentPage),
isLoading: false,
});
}
}
initOldRecords(result) {