Skip to content

Commit

Permalink
feat: optimize ode
Browse files Browse the repository at this point in the history
  • Loading branch information
YangGuoXuan-0503 committed Nov 22, 2023
1 parent 6bd9b73 commit dbe9e0a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions frontend/src/pages/sdoc/sdoc-file-history/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,25 @@ class SdocFileHistory extends React.Component {
onShowChanges = (isShowChanges) => {
if (isShowChanges) {
const { currentVersionContent, currentVersion } = this.state;
this.setState({ isLoading: true }, () => {
this.setState({ isLoading: true, isShowChanges }, () => {
localStorage.setItem('seahub-sdoc-history-show-changes', isShowChanges + '');
seafileAPI.getNextFileRevision(historyRepoID, currentVersion.id, currentVersion.path).then(res => {
return res.data ? seafileAPI.getFileContent(res.data) : { data: '' };
}).then(res => {
const lastVersionContent = res.data;
this.setContent(currentVersionContent, lastVersionContent);
this.setState({ isShowChanges });
}).catch(error => {
const errorMessage = Utils.getErrorMsg(error, true);
toaster.danger(gettext(errorMessage));
this.setContent(currentVersionContent, '');
this.setState({ isShowChanges });
});
});
return;
}
this.setState({ isShowChanges }, () => {
localStorage.setItem('seahub-sdoc-history-show-changes', isShowChanges + '');
this.setState({ isLoading: true, isShowChanges }, () => {
this.setState({ isLoading: false, lastVersionContent: '' }, () => {
localStorage.setItem('seahub-sdoc-history-show-changes', isShowChanges + '');
});
});
};

Expand Down
8 changes: 4 additions & 4 deletions seahub/api2/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3382,12 +3382,12 @@ def get(self, request, repo_id, current_revision_id, format=None):
next_file_history = {}

commit_id = next_file_history.get('commit_id', '')
path = next_file_history.get('path', '')
file_name = os.path.basename(path)

if not commit_id:
return api_error(status.HTTP_404_NOT_FOUND, 'Revision commit_id not found.')
# There is no need to get the content of the commit, just return ''
return Response('')

path = next_file_history.get('path', '')
file_name = os.path.basename(path)
try:
obj_id = seafserv_threaded_rpc.get_file_id_by_commit_and_path(
repo_id, commit_id, path)
Expand Down

0 comments on commit dbe9e0a

Please sign in to comment.