Skip to content

Commit

Permalink
Merge pull request #1428 from oasisprotocol/lw/simplify-selectors
Browse files Browse the repository at this point in the history
Remove selectWalletsPublicKeys
  • Loading branch information
lukaw3d authored Apr 26, 2023
2 parents 31b3573 + f6495d7 commit 96612f8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/app/pages/AccountPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
selectAddress,
selectIsOpen,
selectWallets,
selectWalletsPublicKeys,
selectWalletsAddresses,
} from 'app/state/wallet/selectors'
import { tabBadgeCounterZIndex } from '../../../styles/theme/elementSizes'
import { AccountSummary } from './Features/AccountSummary'
Expand Down Expand Up @@ -100,7 +100,7 @@ export function AccountPage(props: AccountPageProps) {
const selectedNetwork = useSelector(selectSelectedNetwork)
const { active } = useSelector(selectTransaction)
const wallets = useSelector(selectWallets)
const walletsPublicKeys = useSelector(selectWalletsPublicKeys)
const walletsAddresses = useSelector(selectWalletsAddresses)

const balanceDelegations = stake.delegations?.reduce((acc, v) => acc + BigInt(v.amount), 0n)
const balanceDebondingDelegations = stake.debondingDelegations?.reduce(
Expand Down Expand Up @@ -130,9 +130,9 @@ export function AccountPage(props: AccountPageProps) {
for (const wallet of Object.values(wallets)) {
dispatch(walletActions.fetchWallet(wallet))
}
// Using `walletsPublicKeys` dependency instead of `wallets` to avoid infinite loop
// Using `walletsAddresses` dependency instead of `wallets` to avoid infinite loop
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [dispatch, walletsPublicKeys.join(','), selectedNetwork])
}, [dispatch, walletsAddresses.join(','), selectedNetwork])

return (
<Box pad="small">
Expand Down
3 changes: 0 additions & 3 deletions src/app/state/wallet/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ export const selectActiveWallet = createSelector([selectSlice], state => {
})

export const selectWallets = createSelector([selectSlice], state => state.wallets ?? {})
export const selectWalletsPublicKeys = createSelector([selectWallets], wallets =>
Object.values(wallets).map(w => w.publicKey),
)
export const selectAddress = createSelector([selectActiveWallet], wallet => wallet?.address)
export const selectWalletsAddresses = createSelector([selectWallets], wallets =>
Object.values(wallets).map(w => w.address),
Expand Down

0 comments on commit 96612f8

Please sign in to comment.