Fix/list fetch error toast - #8
Merged
Merged
Conversation
The setup module mocks FlashList to RecyclerView — an export that only exists in flash-list v1. Under the repo's flash-list 2.x it registers the mock as undefined, so any test that actually renders FlashList crashes in nativewind's JSX runtime. Nothing rendered it so far, which is why it went unnoticed.
New fetch-error module maps a failed site fetch to a kind and shows a
small centered toast with a localized, cause-specific message.
fetchPage attaches the HTTP status to its errors, so HTTP responses
classify precisely (429 rate-limited, 404/410 removed content, >=500
server trouble, other 4xx request failure — server/http messages carry
the status code, e.g. 'The site is having trouble (502)…'), while
errors without a status split into timeout ('Request timed out') and
offline. Messages added to all seven app languages.
A failed page fetch (e.g. a transient 502 while paging the home feed) sent the whole screen to 'Error loading videos', discarding pages that were already loaded and rendered. List screens now keep their content when a fetch fails with something on screen and surface the classified toast instead; the full error screen remains only when there is nothing to keep. Wired into home, search (which previously failed silently), tag, category, model and author screens via a small useFetchErrorToast hook.
💯 Test Coverage
😎 Tests Results
👀 Tests Details • (53%)
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A failed page fetch (e.g. a transient 502 while paging the home feed) sent the whole screen to 'Error loading videos', throwing away pages that were already loaded and rendered.
List screens now keep their content when a fetch fails with something on screen and surface a small centered toast instead; the full error screen remains only when there is nothing to keep. The toast message is classified per failure (fetchPage attaches the HTTP status): offline, timeout, rate-limited (429), server trouble with status (e.g. 'The site is having trouble (502)…'), removed content (404/410), and other HTTP errors — all localized in the seven app languages. Applied to home, search (which previously failed silently), tag, category, model and author screens.
Also drops the stale '@shopify/flash-list/jestSetup' import from the test utils: it mocks FlashList to a v1-only export that no longer exists in flash-list 2.x (undefined), which made rendering FlashList in tests crash.