Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

Commit

Permalink
revert pagination in accounts model
Browse files Browse the repository at this point in the history
  • Loading branch information
horacioh committed Mar 29, 2024
1 parent b98be1a commit a8c9183
Showing 1 changed file with 5 additions and 25 deletions.
30 changes: 5 additions & 25 deletions frontend/packages/app/models/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {queryKeys} from '@mintter/app/models/query-keys'
import {Account, GRPCClient, Profile} from '@mintter/shared'
import {
UseMutationOptions,
useInfiniteQuery,
useMutation,
useQueries,
useQuery,
Expand Down Expand Up @@ -42,19 +41,13 @@ function getAccountQuery(grpcClient: GRPCClient, accountId?: string) {
export function useAllAccounts(filterSites?: boolean) {
// let isDaemonReady = useDaemonReady()
const grpcClient = useGRPCClient()
const accountsQuery = useInfiniteQuery<
{accounts: Array<Account>},
ConnectError
>({
const contacts = useQuery<{accounts: Array<Account>}, ConnectError>({
// enabled: !!isDaemonReady,
queryKey: [queryKeys.GET_ALL_ACCOUNTS, filterSites],
queryFn: async (context) => {
const listed = await grpcClient.accounts.listAccounts({
pageToken: context.pageParam,
pageSize: 20,
})
queryFn: async () => {
const listed = await grpcClient.accounts.listAccounts({})
if (filterSites) {
return {
...listed,
accounts: listed.accounts.filter(
(account) =>
account.profile?.bio !== 'Hypermedia Site. Powered by Mintter.',
Expand All @@ -66,21 +59,8 @@ export function useAllAccounts(filterSites?: boolean) {
onError: (err) => {
appError(`useAllAccounts Error ${err.code}: ${err.message}`, err.metadata)
},
getNextPageParam: (lastPage) => {
return lastPage.nextPageToken || undefined
},
})

const allAccounts =
accountsQuery.data?.pages.flatMap((page) => page.accounts) ?? []
console.log(`== ~ useAllAccounts ~ accountsQuery:`, accountsQuery)
return {
...accountsQuery,
data: {
...accountsQuery.data,
accounts: allAccounts,
},
}
return contacts
}

export function useSetTrusted(
Expand Down

0 comments on commit a8c9183

Please sign in to comment.