Conversation
There was a problem hiding this comment.
Code Review
This pull request modifies the train routes store to return an empty array instead of throwing an error when no routes are found, treating this as an expected UI state. While this change improves error handling, the feedback identifies a potential UI regression where the 'not-found' state is set unconditionally, which could cause full-screen empty states during 'load more' operations even if previous results exist. Additionally, the store currently retains stale route data from previous searches when a new search returns no results.
| // "No routes" is an expected UI state, not an exceptional failure. | ||
| return [] |
There was a problem hiding this comment.
Returning an empty array instead of throwing is a good improvement for handling expected 'no results' states. However, there is a side effect regarding the UI logic in RouteListScreen:
- UI Regression: Previously, when this function threw an error, the screen's
onErrorhandler would only setresultTypeto"not-found"if the totalrouteDatawas empty. Now, becausegetRoutesupdates the store'sresultTypeunconditionally on line 90 and returns successfully, theNoTrainsFoundMessage(which is a full-screen empty state) will be displayed at the bottom of the list whenever a 'load more' request for a subsequent date fails to find trains, even if the list already contains results from previous dates. - Stale Data: The store's
routesstate is not cleared on line 90. If a previous search was successful, the store will continue to hold those routes even though the current search returned no results.
Consider making the state updates conditional or moving them to the caller to ensure the UI behaves correctly in aggregated views.
Summary
resultTypeset tonot-foundso the UI can show the empty-state messageTesting