Skip to content

fix: combine error states in SorokitProvider and conditionally render Dashboard screens (#583, #585) - #647

Merged
k-deejah merged 2 commits into
Sorokit:mainfrom
Olamidepy:fix/provider-error-and-dashboard-screens
Sep 2, 2026
Merged

fix: combine error states in SorokitProvider and conditionally render Dashboard screens (#583, #585)#647
k-deejah merged 2 commits into
Sorokit:mainfrom
Olamidepy:fix/provider-error-and-dashboard-screens

Conversation

@Olamidepy

@Olamidepy Olamidepy commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Description

This pull request resolves two issues affecting state management and rendering lifecycle:

  1. **Fixes SorokitProvider error state clobbered in Promise.all and not cleared on reconnect or disconnect #583 **: Resolves error state clobbering in Promise.all and ensures errors are cleared on wallet reconnect or disconnect in SorokitProvider.
  2. **Fixes Dashboard SCREENS constant pre-mounts all 5 screens on load causing redundant data fetches #585 **: Replaces static screen instantiation with conditional rendering in Dashboard to prevent redundant data fetching and interval leaks.

Why These Changes Were Needed

1. SorokitProvider Error Handling (#583)

  • Error Clobbering: When loading account data, getAccount and getBalances ran in Promise.all. If both operations encountered an error, the second call's setError silently overwrote the first, displaying only one partial error to the user.
  • Stale Error Persistence on Address Change: Switching accounts did not clear errors from previous sessions before initiating new fetches, leaving misleading banners in TopBar.
  • Disconnect State: Disconnecting the wallet did not clear previous error states.

2. Dashboard Pre-Mounting Screens (#585)

  • Eager Screen Mounts: Dashboard.tsx previously defined screens in a module-level constant map (SCREENS). This caused all 5 screens (and their respective child hooks like TransactionHistory, FeeEstimator, ClaimableBalanceCard, and ContractEventFeed) to mount and execute data fetching immediately upon app startup.
  • Leaked Polling & Intervals: Because all screens remained persistently mounted, switching tabs never unmounted inactive views, accumulating polling intervals and memory overhead.

What Was Changed & How It Was Implemented

src/context/SorokitProvider.tsx

  • Error Reset on Address Change: Added setError(null) at the beginning of the address useEffect hook so stale errors are cleared prior to starting new fetches.
  • Combined Errors: In the Promise.all resolution, joined non-null error strings using a semicolon delimiter (; ):
    const combined = [accountRes.error, balancesRes.error].filter(Boolean).join("; ");
    if (combined) setError(combined);

@drips-wave

drips-wave Bot commented Sep 2, 2026

Copy link
Copy Markdown

@Olamidepy 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

@Olamidepy

Copy link
Copy Markdown
Contributor Author

Merge @k-deejah

@k-deejah
k-deejah merged commit 007a9e2 into Sorokit:main Sep 2, 2026
2 of 4 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

2 participants