mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-23 12:27:48 +00:00
fix axios cancel error not show (#7924)
* fix axios cancel error not show * fix warnings
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import React, { Component, Fragment } from 'react';
|
||||
import axios from 'axios';
|
||||
import PropTypes from 'prop-types';
|
||||
import isHotkey from 'is-hotkey';
|
||||
import classnames from 'classnames';
|
||||
@@ -8,7 +9,7 @@ import searchAPI from '../../utils/search-api';
|
||||
import { gettext } from '../../utils/constants';
|
||||
import SearchResultItem from './search-result-item';
|
||||
import SearchResultLibrary from './search-result-library';
|
||||
import { debounce, Utils, isCanceled } from '../../utils/utils';
|
||||
import { debounce, Utils } from '../../utils/utils';
|
||||
import toaster from '../toast';
|
||||
import Loading from '../loading';
|
||||
import { SEARCH_MASK, SEARCH_CONTAINER } from '../../constants/zIndexes';
|
||||
@@ -398,6 +399,14 @@ class Search extends Component {
|
||||
}, 1);
|
||||
};
|
||||
|
||||
handleError = (e) => {
|
||||
if (!axios.isCancel(e)) {
|
||||
let errMessage = Utils.getErrorMsg(e);
|
||||
toaster.danger(errMessage);
|
||||
}
|
||||
this.setState({ isLoading: false });
|
||||
};
|
||||
|
||||
getRepoSearchResult = (query_str) => {
|
||||
if (this.source) {
|
||||
this.source.cancel('prev request is cancelled');
|
||||
@@ -414,11 +423,7 @@ class Search extends Component {
|
||||
isLoading: false,
|
||||
});
|
||||
}).catch(error => {
|
||||
if (!isCanceled(error)) {
|
||||
let errMessage = Utils.getErrorMsg(error);
|
||||
toaster.danger(errMessage);
|
||||
}
|
||||
this.setState({ isLoading: false });
|
||||
this.handleError(error);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -459,9 +464,7 @@ class Search extends Component {
|
||||
});
|
||||
}
|
||||
}).catch(error => {
|
||||
let errMessage = Utils.getErrorMsg(error);
|
||||
toaster.danger(errMessage);
|
||||
this.setState({ isLoading: false });
|
||||
this.handleError(error);
|
||||
});
|
||||
} else {
|
||||
this.onNormalSearch(queryData, cancelToken, page);
|
||||
@@ -489,9 +492,7 @@ class Search extends Component {
|
||||
isResultGotten: true,
|
||||
});
|
||||
}).catch(error => {
|
||||
let errMessage = Utils.getErrorMsg(error);
|
||||
toaster.danger(errMessage);
|
||||
this.setState({ isLoading: false });
|
||||
this.handleError(error);
|
||||
});
|
||||
};
|
||||
|
||||
|
@@ -1,4 +1,3 @@
|
||||
import axios from 'axios';
|
||||
import { mediaUrl, gettext, serviceURL, siteRoot, isPro, fileAuditEnabled, canGenerateShareLink, canGenerateUploadLink, shareLinkPasswordMinLength, username, folderPermEnabled, onlyofficeConverterExtensions, enableSeadoc, enableRepoSnapshotLabel,
|
||||
enableResetEncryptedRepoPassword, isEmailConfigured, isSystemStaff,
|
||||
enableOnlyoffice, onlyofficeEditFileExtension,
|
||||
@@ -1998,7 +1997,3 @@ export const throttle = (func, delay) => {
|
||||
export const getType = (value) => {
|
||||
return Object.prototype.toString.call(value).slice(8, -1);
|
||||
};
|
||||
|
||||
export const isCanceled = (error) => {
|
||||
return axios.isCancel(error);
|
||||
};
|
||||
|
Reference in New Issue
Block a user