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