-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: mf-6371 infinite loading in DAO tab (#11828)
- Loading branch information
Showing
6 changed files
with
51 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 8 additions & 6 deletions
14
packages/plugins/Snapshot/src/SiteAdaptor/hooks/useCurrentAccountFollowSpaceList.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
import { useChainContext } from '@masknet/web3-hooks-base' | ||
import { Snapshot } from '@masknet/web3-providers' | ||
import { useAsyncRetry } from 'react-use' | ||
import { useQuery } from '@tanstack/react-query' | ||
|
||
export function useCurrentAccountFollowSpaceList() { | ||
const { account } = useChainContext() | ||
return useQuery({ | ||
queryKey: ['following-space-list', account], | ||
async queryFn() { | ||
if (!account) return [] | ||
|
||
return useAsyncRetry(async () => { | ||
if (!account) return | ||
|
||
return Snapshot.getFollowingSpaceIdList(account) | ||
}, [account]) | ||
return Snapshot.getFollowingSpaceIdList(account) | ||
}, | ||
}) | ||
} |
14 changes: 8 additions & 6 deletions
14
packages/plugins/Snapshot/src/SiteAdaptor/hooks/useProposalList.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,13 @@ | ||
import { useAsyncRetry } from 'react-use' | ||
import { EMPTY_LIST } from '@masknet/shared-base' | ||
import { Snapshot } from '@masknet/web3-providers' | ||
import type { SnapshotBaseAPI } from '@masknet/web3-providers/types' | ||
import { useQuery } from '@tanstack/react-query' | ||
|
||
export function useProposalList(spaceId: string, strategyName?: string) { | ||
return useAsyncRetry<SnapshotBaseAPI.SnapshotProposal[]>(async () => { | ||
if (!spaceId) return EMPTY_LIST | ||
return Snapshot.getProposalListBySpace(spaceId, strategyName) | ||
}, [spaceId, strategyName]) | ||
return useQuery({ | ||
queryKey: ['proposal-list', spaceId, strategyName], | ||
queryFn: async () => { | ||
if (!spaceId) return EMPTY_LIST | ||
return Snapshot.getProposalListBySpace(spaceId, strategyName) | ||
}, | ||
}) | ||
} |
14 changes: 8 additions & 6 deletions
14
packages/plugins/Snapshot/src/SiteAdaptor/hooks/useSpace.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
import { useAsyncRetry } from 'react-use' | ||
import { Snapshot } from '@masknet/web3-providers' | ||
import type { SnapshotBaseAPI } from '@masknet/web3-providers/types' | ||
import { useQuery } from '@tanstack/react-query' | ||
|
||
export function useSpace(spaceId: string) { | ||
return useAsyncRetry<SnapshotBaseAPI.SnapshotSpace | undefined>(async () => { | ||
if (!spaceId) return | ||
return Snapshot.getSpace(spaceId) | ||
}, [spaceId]) | ||
return useQuery({ | ||
queryKey: ['space', spaceId], | ||
async queryFn() { | ||
if (!spaceId) return null | ||
return Snapshot.getSpace(spaceId) | ||
}, | ||
}) | ||
} |