-
Notifications
You must be signed in to change notification settings - Fork 149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: stx fallback btn show on load #5665
Conversation
WalkthroughThe recent updates to the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant AssetList
participant CurrentStacksAccountLoader
User->>AssetList: Render AssetList
AssetList->>CurrentStacksAccountLoader: Check current account and Ledger keys
CurrentStacksAccountLoader-->>AssetList: Return account status
alt Account available and Ledger keys present
AssetList->>User: Show assets
else No account or Ledger keys
AssetList->>User: Render null (no fallback)
end
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
const isLedger = useHasLedgerKeys(); | ||
|
||
if (!currentAccount && !isLedger) return null; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the loader should ever return something other than child or fallback.
Maybe this should be fixed in the instance of CurrentStacksAccountLoader
and not inside of it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
smth like this?
<CurrentStacksAccountLoader
fallback={
!currentAccount && !isLedger ? null : (
<ConnectLedgerAssetItemFallback
chain="stacks"
icon={<StxAvatarIcon />}
symbol="STX"
variant={variant}
/>
)
}
>
dbd7e55
to
b13d6e3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (1)
- src/app/features/asset-list/asset-list.tsx (3 hunks)
Additional comments not posted (2)
src/app/features/asset-list/asset-list.tsx (2)
23-24
: LGTM! Imports are correct.The import statements for
useCurrentStacksAccount
anduseHasLedgerKeys
are correct and necessary for the changes made in the component.
39-40
: LGTM! Hooks are used correctly.The
useCurrentStacksAccount
anduseHasLedgerKeys
hooks are used correctly to manage the account and ledger key states.
!currentAccount && !isLedger ? null : ( | ||
<ConnectLedgerAssetItemFallback | ||
chain="stacks" | ||
icon={<StxAvatarIcon />} | ||
symbol="STX" | ||
variant={variant} | ||
/> | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix the conditional rendering logic.
The conditional rendering logic for the fallback component is incorrect. The fallback should render null
if both currentAccount
and isLedger
are not present.
- !currentAccount && !isLedger ? null : (
+ !currentAccount || !isLedger ? null : (
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
!currentAccount && !isLedger ? null : ( | |
<ConnectLedgerAssetItemFallback | |
chain="stacks" | |
icon={<StxAvatarIcon />} | |
symbol="STX" | |
variant={variant} | |
/> | |
) | |
!currentAccount || !isLedger ? null : ( | |
<ConnectLedgerAssetItemFallback | |
chain="stacks" | |
icon={<StxAvatarIcon />} | |
symbol="STX" | |
variant={variant} | |
/> | |
) |
useAtomValue(stacksAccountState)
initially returns empty array on page load, it leads to short display ofConnect Stacks
btn (which we show in btc only ledger mode)I believe we need to refactor this and remove usage of atom?
but for now it's prob better just to hide stacks row rather than show fallback btn
wdyt?
Summary by CodeRabbit
New Features
AssetList
component to conditionally display content based on the user's active Stacks account and Ledger key availability.Bug Fixes