Skip to content

Commit

Permalink
fix: the bug (#1580)
Browse files Browse the repository at this point in the history
  • Loading branch information
paschalidi authored Mar 25, 2021
1 parent 6a75e9c commit c491a00
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ const getFiltersForAttributesSearchQuery = (formValues) => {

return [...stringFilters, ...rangeFilers];
};

const handleErrors = ({ httpStatusCode, message }) => {
if (httpStatusCode === 409 && message === 'maxteicountreached') {
return of(showTooManyResultsViewOnSearchPage());
}
return of(showErrorViewOnSearchPage());
};

const searchViaAttributesStream = (queryArgs, attributes, triggeredFrom) =>
from(getTrackedEntityInstances(queryArgs, attributes)).pipe(
map(({ trackedEntityInstanceContainers: searchResults, pagingData }) => {
Expand All @@ -79,12 +87,7 @@ const searchViaAttributesStream = (queryArgs, attributes, triggeredFrom) =>
return showEmptyResultsViewOnSearchPage();
}),
startWith(showLoadingViewOnSearchPage()),
catchError(({ httpStatusCode, message }) => {
if (httpStatusCode === 409 && message === 'maxteicountreached') {
return of(showTooManyResultsViewOnSearchPage());
}
return of(showErrorViewOnSearchPage());
}),
catchError(handleErrors),
);

export const searchViaUniqueIdOnScopeProgramEpic: Epic = (action$, store) =>
Expand Down Expand Up @@ -259,7 +262,7 @@ export const fallbackSearchEpic: Epic = (action$: InputObservable) =>
return of(showEmptyResultsViewOnSearchPage());
}),
startWith(showLoadingViewOnSearchPage()),
catchError(() => of(showErrorViewOnSearchPage())),
catchError(handleErrors),
);
}),
);
Expand Down

0 comments on commit c491a00

Please sign in to comment.