Skip to content
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

Convert Chain Selection DropdownMenu to Backend Networks #6344

Merged
merged 6 commits into from
Dec 23, 2024

Conversation

walmat
Copy link
Contributor

@walmat walmat commented Dec 17, 2024

What changed (plus any additional context for devs)

Changes all context menus that are chain selectors to use Zeego. We now no longer rely on local ios/ assets to deliver the chain badges inside of those dropdowns and can rely on remote backend networks. These are located in three places

  1. Swaps (input filter / output filter / preferred network)
  2. Claimables
  3. AvailableNetworks on Expanded Asset Sheet

Work that's left to do

  • Need to figure out how to add hit slop into the Zeego powered DropdownMenu still
  • Probably would be a good idea to set a max height on the dropdown menu so that it doesn't overflow off the screen

Screen recordings / screenshots

https://rainbowhaus.slack.com/archives/C0468CDBE75/p1734480680880539

What to test

need to test that functionally the chain selection in all these places remains unchanged.

@walmat walmat changed the title start work on converting existing chain selection dropdowns to Zeego Convert Chain Selection DropdownMenu to Backend Networks Dec 17, 2024
@@ -75,6 +92,8 @@ export function DropdownMenu<T extends string>({
side = 'right',
alignOffset = 5,
avoidCollisions = true,
hitSlop = 12, // TODO: Figure out how to make the trigger hit slop work
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note for self

@walmat walmat marked this pull request as ready for review December 17, 2024 21:51
@brunobar79
Copy link
Member

Launch in simulator or device for 7c58c28

},
[convertAssetAndNavigate]
);
const handlePressContextMenu = useCallback((chainId: string) => convertAssetAndNavigate(+chainId), [convertAssetAndNavigate]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe (not sure if good idea) we could make convertAssetAndNavigate take string and convert inside, to not need the useCallback

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah actually just notice DropdownMenu is not memoed so the fn being stable or not does not make a difference, the useCallback is just overhead rn, don't think we can easily memo it since it takes children

},
}));

const MenuWrapper = availableChainIds.length > 1 ? ContextMenuButton : Box;
const Children = useMemo(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

children is memo maybe it works I never tested returning components from useMemo

const backendNetworks = get().backendNetworks;
return backendNetworks.networks.reduce(
(acc, backendNetwork) => {
acc[parseInt(backendNetwork.id, 10)] = backendNetwork.icons.badgeURL;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see we do this parseInt(x, 10) sporadically why is that? what's the second arg 10 for?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can call getChainsBadgeWorklet here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true. I will probably do a cleanup PR to this file here soon but don't want to muddy it in this PR.

@brunobar79
Copy link
Member

Launch in simulator or device for 2066fdf

Copy link
Contributor

@ibrahimtaveras00 ibrahimtaveras00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@walmat walmat changed the base branch from develop to @matthew/backend-chain-badge December 23, 2024 17:49
@walmat walmat merged commit e093c7a into @matthew/backend-chain-badge Dec 23, 2024
4 checks passed
@walmat walmat deleted the @matthew/remote-chain-selectors branch December 23, 2024 18:19
@brunobar79
Copy link
Member

Launch in simulator or device for 5709e66

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.

4 participants