fix prefetch returning undefined (#8538)

This commit is contained in:
Samuel Newman
2025-06-19 19:25:17 +03:00
committed by GitHub
parent 9be3b0794c
commit d53fdb0dda
2 changed files with 12 additions and 7 deletions
@@ -1,6 +1,10 @@
import React from 'react' import React from 'react'
import {StyleProp, View, ViewStyle} from 'react-native' import {type StyleProp, View, type ViewStyle} from 'react-native'
import {AppBskyFeedDefs, AppBskyFeedPostgate, AtUri} from '@atproto/api' import {
type AppBskyFeedDefs,
type AppBskyFeedPostgate,
AtUri,
} from '@atproto/api'
import {msg, Trans} from '@lingui/macro' import {msg, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import {useQueryClient} from '@tanstack/react-query' import {useQueryClient} from '@tanstack/react-query'
@@ -22,7 +26,7 @@ import {
import { import {
createThreadgateViewQueryKey, createThreadgateViewQueryKey,
getThreadgateView, getThreadgateView,
ThreadgateAllowUISetting, type ThreadgateAllowUISetting,
threadgateViewToAllowUISetting, threadgateViewToAllowUISetting,
useSetThreadgateAllowMutation, useSetThreadgateAllowMutation,
useThreadgateViewQuery, useThreadgateViewQuery,
@@ -558,7 +562,8 @@ export function usePrefetchPostInteractionSettings({
await Promise.all([ await Promise.all([
queryClient.prefetchQuery({ queryClient.prefetchQuery({
queryKey: createPostgateQueryKey(postUri), queryKey: createPostgateQueryKey(postUri),
queryFn: () => getPostgateRecord({agent, postUri}), queryFn: () =>
getPostgateRecord({agent, postUri}).then(res => res ?? null),
staleTime: STALE.SECONDS.THIRTY, staleTime: STALE.SECONDS.THIRTY,
}), }),
queryClient.prefetchQuery({ queryClient.prefetchQuery({
+3 -3
View File
@@ -2,10 +2,10 @@ import React from 'react'
import { import {
AppBskyEmbedRecord, AppBskyEmbedRecord,
AppBskyEmbedRecordWithMedia, AppBskyEmbedRecordWithMedia,
AppBskyFeedDefs, type AppBskyFeedDefs,
AppBskyFeedPostgate, AppBskyFeedPostgate,
AtUri, AtUri,
BskyAgent, type BskyAgent,
} from '@atproto/api' } from '@atproto/api'
import {useMutation, useQuery, useQueryClient} from '@tanstack/react-query' import {useMutation, useQuery, useQueryClient} from '@tanstack/react-query'
@@ -139,7 +139,7 @@ export function usePostgateQuery({postUri}: {postUri: string}) {
staleTime: STALE.SECONDS.THIRTY, staleTime: STALE.SECONDS.THIRTY,
queryKey: createPostgateQueryKey(postUri), queryKey: createPostgateQueryKey(postUri),
async queryFn() { async queryFn() {
return (await getPostgateRecord({agent, postUri})) ?? null return await getPostgateRecord({agent, postUri}).then(res => res ?? null)
}, },
}) })
} }