Skip to content

Commit

Permalink
refactor select
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljscript committed Apr 25, 2024
1 parent 6ec4931 commit a33ec71
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import {useDappConnector} from '@yoroi/dapp-connector'
import {DappConnection} from '@yoroi/dapp-connector/src/adapters/async-storage'
import {useQuery, UseQueryOptions} from 'react-query'

import {useSelectedWallet} from '../../../features/WalletManager/Context'

export const useDAppsConnected = (options?: UseQueryOptions<string[], Error, string[], [string, string]>) => {
export const useDAppsConnected = (options?: UseQueryOptions<DappConnection[], Error, string[], [string, string]>) => {
const wallet = useSelectedWallet()
const {manager} = useDappConnector()

return useQuery({
suspense: true,
...options,
queryKey: [wallet.id, 'dappsConnected'],
queryFn: async () => {
const connections = await manager.listAllConnections()
queryFn: () => manager.listAllConnections(),
select: (connections) => {
const currentWalletConnections = connections.filter((c) => c.walletId === wallet.id)
return currentWalletConnections.map((c) => c.dappOrigin)
},
Expand Down

0 comments on commit a33ec71

Please sign in to comment.