Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/wallet/src/hooks/use-synchronized-refetch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ export function useSynchronizedRefetch(address: string) {

await Promise.all(
activeQueries.map(async query => {
await queryClient.invalidateQueries({ queryKey: query.queryKey })
await queryClient.refetchQueries({
queryKey: query.queryKey,
exact: true,
stale: true,
})
}),
)
Expand Down
12 changes: 6 additions & 6 deletions packages/wallet/src/data/api/routers/collectibles.ts
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for future reference: changes to cache would not apply for use case when api exposed in a separate project called via trpc fetchRequestHandler with fetch from apps

Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ export const collectiblesRouter = router({
}),
)
.query(async ({ input }) => {
const inputHash = JSON.stringify(input)
return await cachedPage(inputHash)
const timestamp = Math.floor(Date.now() / (30 * 1000))
const inputWithTime = { ...input, _cacheTime: timestamp }
return await cachedPage(JSON.stringify(inputWithTime))
}),
collectible: publicProcedure
.input(
Expand All @@ -78,10 +79,9 @@ export const collectiblesRouter = router({
})

const cachedPage = cache(async (key: string) => {
const { address, networks, pages, limit, offset, search, sort } =
JSON.parse(key)

return await page({ address, networks, pages, limit, offset, search, sort })
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { _cacheTime, ...input } = JSON.parse(key)
return await page(input)
})

async function page({
Expand Down
1 change: 1 addition & 0 deletions packages/wallet/src/data/services/alchemy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,7 @@ export async function getNFTs(
url.searchParams.set('owner', address)
url.searchParams.set('withMetadata', 'true')
url.searchParams.set('pageSize', pageSize ?? '100')
url.searchParams.set('orderBy', 'transferTime')
if (page) {
url.searchParams.set('pageKey', page)
}
Expand Down
Loading