Skip to content

fix(frontend): distinguish an empty trade list from a fetch error - #433

Merged
dark-sarge merged 2 commits into
arflexx:mainfrom
zeemscript:fix/issue-282
Oct 1, 2026
Merged

dark-sarge merged 2 commits into
arflexx:mainfrom
zeemscript:fix/issue-282

Conversation

@zeemscript

Copy link
Copy Markdown
Contributor

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: adds isEmpty, true only when a load succeeded with zero trades; false while loading and false when error is set (mutually exclusive). error remains non-null only on failure.
  • components/MarketplaceListings.tsx (the homepage trade list): now tracks an error state — a non-OK HTTP response or a thrown fetch sets it (previously a non-OK response was silently ignored), renders an inline role="alert" error banner with a Retry button, and renders the empty state only on a successful zero-result load.

Tests — 12 passed (npx tsc --noEmit clean)

  • useTradeList: success-empty ⇒ isEmpty true / error null; failure ⇒ error set / isEmpty false; success-non-empty ⇒ isEmpty false.
  • 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 was isEmpty plus the homepage error/empty UI (the homepage's list is MarketplaceListings, which fetches itself rather than consuming the hook).

…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
@drips-wave

drips-wave Bot commented Sep 30, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@dark-sarge
dark-sarge merged commit 352fe8e into arflexx:main Oct 1, 2026
3 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[frontend] - useTradeList hook cannot distinguish empty response from network error

2 participants