Skip to content

Commit

Permalink
fix(assistant): Fixes possible bug when incorrect data is returned fo…
Browse files Browse the repository at this point in the history
…r trip patterns

fixes #598
  • Loading branch information
mikaelbr committed Oct 27, 2020
1 parent ab73c09 commit 73d2270
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/screens/Assistant/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -577,12 +577,15 @@ function useTripPatterns(
},
);
source.token.throwIfRequested();
setTripPatterns(response.data);
setSearchState(
response.data.length >= 1 ? 'search-success' : 'search-empty-result',
);

setTimeOfSearch(searchDate);
if (Array.isArray(response.data)) {
setTripPatterns(response.data);
setSearchState(
response.data.length >= 1
? 'search-success'
: 'search-empty-result',
);
}
} catch (e) {
if (!isCancel(e)) {
setErrorType(getAxiosErrorType(e));
Expand Down

0 comments on commit 73d2270

Please sign in to comment.