-
Notifications
You must be signed in to change notification settings - Fork 40
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
[BX-1294] Fix missing wallets in Send flow #1368
Conversation
Here's the packed extension for this build: |
Here's the packed extension for this build: |
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.
Functionality looks good to me; didn't review code
const [newWalletOrder, setNewWalletOrder] = useState<`0x${string}`[]>([]); | ||
const { walletOrder, saveWalletOrder } = useWalletOrderStore(); | ||
|
||
// find the items in getAccounts then compare to the current | ||
// walletOrder, then return all items in getAccounts in order | ||
|
||
useEffect(() => { | ||
const combineAndOrderArrays = async (orderArray: string[]) => { | ||
const orderSet = new Set(orderArray); | ||
const primaryArray = await getAccounts(); | ||
const itemsNotInOrderArray = primaryArray.filter( | ||
(item) => !orderSet.has(item), | ||
); | ||
|
||
const primaryMap = new Map(primaryArray.map((item) => [item, item])); | ||
|
||
const combinedAndOrdered = [ | ||
...orderArray.filter((item) => primaryMap.has(item)), | ||
...itemsNotInOrderArray, | ||
]; | ||
|
||
return combinedAndOrdered; | ||
}; | ||
|
||
combineAndOrderArrays(walletOrder).then((orderedAccounts) => { | ||
setNewWalletOrder(orderedAccounts as `0x${string}`[]); | ||
saveWalletOrder(orderedAccounts as `0x${string}`[]); | ||
}); | ||
}, [walletOrder, saveWalletOrder]); | ||
|
||
const sortedWallets = useMemo( | ||
() => sortWallets(walletOrder, wallets), | ||
[wallets, walletOrder], | ||
() => sortWallets(newWalletOrder, wallets), | ||
[newWalletOrder, wallets], | ||
); | ||
const sortedWatchedWallets = useMemo( | ||
() => sortWallets(walletOrder, watchedWallets), | ||
[watchedWallets, walletOrder], | ||
() => sortWallets(newWalletOrder, watchedWallets), | ||
[newWalletOrder, watchedWallets], | ||
); |
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.
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.
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.
changed lol
Here's the packed extension for this build: |
Fixes BX-1294
What changed (plus any additional context for devs)
useWalletOrderStore()
and returning those. this was only ever updated when the order was changed in the walletSwitcher.getAccounts()
and then compare that to the order of the wallets inuseWalletOrderStore()
useWalletOrderStore()
with all the wallets in the correct order and also updated theuseWalletOrderStore()
What to test
Screen recordings / screenshots
Screen.Recording.2024-02-28.at.4.14.30.PM.mov