Repository navigation
fix(frontend): distinguish an empty trade list from a fetch error - #433
Merged
Merged
Conversation
…flexx#282) `useTradeList` (and the homepage listings component) collapsed "no listings" and "failed to load" into the same empty array, so the empty state showed even during an error. - `useTradeList` exposes `isEmpty`, true only when a load **succeeded** with zero trades; it is `false` while loading and `false` when `error` is set, so the two states are mutually exclusive. `error` remains non-null only on failure. - `MarketplaceListings` (the homepage trade list) now tracks an `error` state: a non-OK response or a thrown fetch sets it (previously a non-OK response was ignored entirely), renders an inline error banner with a Retry button, and only renders the empty state when the load succeeded with no results. Tests: `useTradeList` success-empty / failure / success-non-empty, and `MarketplaceListings` error-banner-vs-empty-state. 12 passed; `tsc` clean. Closes arflexx#282
|
@zeemscript Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
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.
Closes #282
useTradeList— and the homepage listings component — collapsed "no listings" and "failed to load" into the same empty array, so the empty state showed even during an error.Changes
hooks/useTradeList.ts: addsisEmpty,trueonly when a load succeeded with zero trades;falsewhile loading andfalsewhenerroris set (mutually exclusive).errorremains non-null only on failure.components/MarketplaceListings.tsx(the homepage trade list): now tracks anerrorstate — a non-OK HTTP response or a thrown fetch sets it (previously a non-OK response was silently ignored), renders an inlinerole="alert"error banner with a Retry button, and renders the empty state only on a successful zero-result load.Tests — 12 passed (
npx tsc --noEmitclean)useTradeList: success-empty ⇒isEmptytrue /errornull; failure ⇒errorset /isEmptyfalse; success-non-empty ⇒isEmptyfalse.MarketplaceListings: a failing filtered fetch shows the error banner and not the empty state; an empty successful list shows the empty state and no alert.Note: the hook already exposed
error; the missing half wasisEmptyplus the homepage error/empty UI (the homepage's list isMarketplaceListings, which fetches itself rather than consuming the hook).