fix: Logs double api is called (#1947)

This commit is contained in:
Palash Gupta 2022-12-30 13:59:02 +05:30 committed by GitHub
parent f0e13784e5
commit 27cd514fa5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -120,14 +120,23 @@ function SearchFilter({
const urlQuery = useUrlQuery();
const urlQueryString = urlQuery.get('q');
const debouncedHandleSearch = useMemo(() => debounce(handleSearch, 600), [
handleSearch,
]);
useEffect(() => {
const debouncedHandleSearch = debounce(handleSearch, 600);
debouncedHandleSearch(urlQueryString || '');
return (): void => {
debouncedHandleSearch.cancel();
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [urlQueryString, maxTime, minTime, idEnd, idStart, logLinesPerPage]);
}, [
urlQueryString,
maxTime,
minTime,
idEnd,
idStart,
logLinesPerPage,
dispatch,
]);
return (
<Container>
@ -161,7 +170,6 @@ function SearchFilter({
debouncedupdateQueryString(value);
}}
allowClear
onSearch={handleSearch}
/>
</Popover>
</Container>
@ -169,12 +177,8 @@ function SearchFilter({
}
interface DispatchProps {
getLogs: (
props: Parameters<typeof getLogs>[0],
) => (dispatch: Dispatch<AppActions>) => void;
getLogsAggregate: (
props: Parameters<typeof getLogsAggregate>[0],
) => (dispatch: Dispatch<AppActions>) => void;
getLogs: typeof getLogs;
getLogsAggregate: typeof getLogsAggregate;
}
type SearchFilterProps = DispatchProps;