[SDK] Migrate discovery and post-thread queries to the appview client (#11355)
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,10 +1,5 @@
|
|||||||
import {useCallback, useMemo, useRef} from 'react'
|
import {useCallback, useMemo, useRef} from 'react'
|
||||||
import {
|
import {type AppBskyFeedDefs, AtUri, moderatePost} from '@atproto/api'
|
||||||
type AppBskyFeedDefs,
|
|
||||||
type AppBskyFeedSearchPostsV2,
|
|
||||||
AtUri,
|
|
||||||
moderatePost,
|
|
||||||
} from '@atproto/api'
|
|
||||||
import {
|
import {
|
||||||
type InfiniteData,
|
type InfiniteData,
|
||||||
type QueryClient,
|
type QueryClient,
|
||||||
@@ -13,8 +8,9 @@ import {
|
|||||||
} from '@tanstack/react-query'
|
} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {useModerationOpts} from '#/state/preferences/moderation-opts'
|
import {useModerationOpts} from '#/state/preferences/moderation-opts'
|
||||||
import {useAgent} from '#/state/session'
|
import {useAppviewClient} from '#/state/session'
|
||||||
import {type SearchFilters} from '#/screens/Search/searchParams'
|
import {type SearchFilters} from '#/screens/Search/searchParams'
|
||||||
|
import {app} from '#/lexicons'
|
||||||
import {
|
import {
|
||||||
appendFromMe,
|
appendFromMe,
|
||||||
buildSearchPostsV2Filters,
|
buildSearchPostsV2Filters,
|
||||||
@@ -48,7 +44,7 @@ export function useSearchPostsV2Query({
|
|||||||
enabled?: boolean
|
enabled?: boolean
|
||||||
filters?: SearchFilters
|
filters?: SearchFilters
|
||||||
}) {
|
}) {
|
||||||
const agent = useAgent()
|
const client = useAppviewClient()
|
||||||
const moderationOpts = useModerationOpts()
|
const moderationOpts = useModerationOpts()
|
||||||
const selectArgs = useMemo(
|
const selectArgs = useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
@@ -59,15 +55,15 @@ export function useSearchPostsV2Query({
|
|||||||
[query, filters?.author, filters?.from, moderationOpts],
|
[query, filters?.author, filters?.from, moderationOpts],
|
||||||
)
|
)
|
||||||
const lastRun = useRef<{
|
const lastRun = useRef<{
|
||||||
data: InfiniteData<AppBskyFeedSearchPostsV2.OutputSchema>
|
data: InfiniteData<app.bsky.feed.searchPostsV2.$OutputBody>
|
||||||
args: typeof selectArgs
|
args: typeof selectArgs
|
||||||
result: InfiniteData<AppBskyFeedSearchPostsV2.OutputSchema>
|
result: InfiniteData<app.bsky.feed.searchPostsV2.$OutputBody>
|
||||||
} | null>(null)
|
} | null>(null)
|
||||||
|
|
||||||
return useInfiniteQuery<
|
return useInfiniteQuery<
|
||||||
AppBskyFeedSearchPostsV2.OutputSchema,
|
app.bsky.feed.searchPostsV2.$OutputBody,
|
||||||
Error,
|
Error,
|
||||||
InfiniteData<AppBskyFeedSearchPostsV2.OutputSchema>,
|
InfiniteData<app.bsky.feed.searchPostsV2.$OutputBody>,
|
||||||
QueryKey,
|
QueryKey,
|
||||||
string | undefined
|
string | undefined
|
||||||
>({
|
>({
|
||||||
@@ -79,9 +75,18 @@ export function useSearchPostsV2Query({
|
|||||||
* dialog; see buildSearchPostsV2Filters for how the two sources combine.
|
* dialog; see buildSearchPostsV2Filters for how the two sources combine.
|
||||||
*/
|
*/
|
||||||
const {q, ...embedded} = extractSearchPostsParams(query)
|
const {q, ...embedded} = extractSearchPostsParams(query)
|
||||||
const builtFilters = buildSearchPostsV2Filters(embedded, filters)
|
/*
|
||||||
|
* The generated params brand format-constrained strings (uri,
|
||||||
|
* at-identifier, language) as template-literal types. The builder emits
|
||||||
|
* plain strings parsed from user input, which are runtime-identical, so
|
||||||
|
* the brand is asserted rather than re-validated here.
|
||||||
|
*/
|
||||||
|
const builtFilters = buildSearchPostsV2Filters(
|
||||||
|
embedded,
|
||||||
|
filters,
|
||||||
|
) as app.bsky.feed.searchPostsV2.$Params
|
||||||
const finalQuery = appendFromMe(q, filters?.from === 'me')
|
const finalQuery = appendFromMe(q, filters?.from === 'me')
|
||||||
const res = await agent.app.bsky.feed.searchPostsV2({
|
return await client.call(app.bsky.feed.searchPostsV2, {
|
||||||
...builtFilters,
|
...builtFilters,
|
||||||
query: finalQuery,
|
query: finalQuery,
|
||||||
limit: 25,
|
limit: 25,
|
||||||
@@ -93,13 +98,12 @@ export function useSearchPostsV2Query({
|
|||||||
sort: sort === 'latest' ? 'recent' : sort,
|
sort: sort === 'latest' ? 'recent' : sort,
|
||||||
allTime: true,
|
allTime: true,
|
||||||
})
|
})
|
||||||
return res.data
|
|
||||||
},
|
},
|
||||||
initialPageParam: undefined,
|
initialPageParam: undefined,
|
||||||
getNextPageParam: lastPage => lastPage.cursor,
|
getNextPageParam: lastPage => lastPage.cursor,
|
||||||
enabled: enabled ?? !!moderationOpts,
|
enabled: enabled ?? !!moderationOpts,
|
||||||
select: useCallback(
|
select: useCallback(
|
||||||
(data: InfiniteData<AppBskyFeedSearchPostsV2.OutputSchema>) => {
|
(data: InfiniteData<app.bsky.feed.searchPostsV2.$OutputBody>) => {
|
||||||
const {moderationOpts, isSearchingSpecificUser} = selectArgs
|
const {moderationOpts, isSearchingSpecificUser} = selectArgs
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -177,7 +181,7 @@ export function* findAllPostsInQueryData(
|
|||||||
uri: string,
|
uri: string,
|
||||||
): Generator<AppBskyFeedDefs.PostView, undefined> {
|
): Generator<AppBskyFeedDefs.PostView, undefined> {
|
||||||
const queryDatas = queryClient.getQueriesData<
|
const queryDatas = queryClient.getQueriesData<
|
||||||
InfiniteData<AppBskyFeedSearchPostsV2.OutputSchema>
|
InfiniteData<app.bsky.feed.searchPostsV2.$OutputBody>
|
||||||
>({
|
>({
|
||||||
queryKey: [searchPostsQueryKeyRoot],
|
queryKey: [searchPostsQueryKeyRoot],
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
import {useQuery} from '@tanstack/react-query'
|
import {useQuery} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {STALE} from '#/state/queries'
|
import {STALE} from '#/state/queries'
|
||||||
import {useAgent} from '#/state/session'
|
import {useAppviewClient} from '#/state/session'
|
||||||
|
import {app} from '#/lexicons'
|
||||||
|
|
||||||
type ServiceConfig = {
|
type ServiceConfig = {
|
||||||
checkEmailConfirmed: boolean
|
checkEmailConfirmed: boolean
|
||||||
@@ -13,17 +14,17 @@ type ServiceConfig = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function useServiceConfigQuery() {
|
export function useServiceConfigQuery() {
|
||||||
const agent = useAgent()
|
const client = useAppviewClient()
|
||||||
return useQuery<ServiceConfig>({
|
return useQuery<ServiceConfig>({
|
||||||
refetchOnWindowFocus: true,
|
refetchOnWindowFocus: true,
|
||||||
staleTime: STALE.MINUTES.FIVE,
|
staleTime: STALE.MINUTES.FIVE,
|
||||||
queryKey: ['service-config'],
|
queryKey: ['service-config'],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
try {
|
try {
|
||||||
const {data} = await agent.api.app.bsky.unspecced.getConfig()
|
const data = await client.call(app.bsky.unspecced.getConfig)
|
||||||
return {
|
return {
|
||||||
checkEmailConfirmed: Boolean(data.checkEmailConfirmed),
|
checkEmailConfirmed: Boolean(data.checkEmailConfirmed),
|
||||||
// @ts-expect-error not included in types atm
|
// @ts-expect-error not included in the lexicon atm
|
||||||
topicsEnabled: Boolean(data.topicsEnabled),
|
topicsEnabled: Boolean(data.topicsEnabled),
|
||||||
liveNow: data.liveNow ?? [],
|
liveNow: data.liveNow ?? [],
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import {type AppBskyGraphSearchStarterPacksV2} from '@atproto/api'
|
|
||||||
import {
|
import {
|
||||||
type InfiniteData,
|
type InfiniteData,
|
||||||
keepPreviousData,
|
keepPreviousData,
|
||||||
@@ -7,7 +6,8 @@ import {
|
|||||||
} from '@tanstack/react-query'
|
} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {STALE} from '#/state/queries'
|
import {STALE} from '#/state/queries'
|
||||||
import {useAgent} from '#/state/session'
|
import {useAppviewClient} from '#/state/session'
|
||||||
|
import {app} from '#/lexicons'
|
||||||
|
|
||||||
export const RQKEY_ROOT = 'starter-pack-search'
|
export const RQKEY_ROOT = 'starter-pack-search'
|
||||||
export const RQKEY = (query: string, limit?: number) => [
|
export const RQKEY = (query: string, limit?: number) => [
|
||||||
@@ -27,23 +27,22 @@ export function useStarterPackSearch({
|
|||||||
maintainData?: boolean
|
maintainData?: boolean
|
||||||
limit?: number
|
limit?: number
|
||||||
}) {
|
}) {
|
||||||
const agent = useAgent()
|
const client = useAppviewClient()
|
||||||
return useInfiniteQuery<
|
return useInfiniteQuery<
|
||||||
AppBskyGraphSearchStarterPacksV2.OutputSchema,
|
app.bsky.graph.searchStarterPacksV2.$OutputBody,
|
||||||
Error,
|
Error,
|
||||||
InfiniteData<AppBskyGraphSearchStarterPacksV2.OutputSchema>,
|
InfiniteData<app.bsky.graph.searchStarterPacksV2.$OutputBody>,
|
||||||
QueryKey,
|
QueryKey,
|
||||||
string | undefined
|
string | undefined
|
||||||
>({
|
>({
|
||||||
staleTime: STALE.MINUTES.FIVE,
|
staleTime: STALE.MINUTES.FIVE,
|
||||||
queryKey: RQKEY(query, limit),
|
queryKey: RQKEY(query, limit),
|
||||||
queryFn: async ({pageParam}) => {
|
queryFn: async ({pageParam}) => {
|
||||||
const res = await agent.app.bsky.graph.searchStarterPacksV2({
|
return await client.call(app.bsky.graph.searchStarterPacksV2, {
|
||||||
q: query,
|
q: query,
|
||||||
limit,
|
limit,
|
||||||
cursor: pageParam,
|
cursor: pageParam,
|
||||||
})
|
})
|
||||||
return res.data
|
|
||||||
},
|
},
|
||||||
enabled: enabled && !!query,
|
enabled: enabled && !!query,
|
||||||
initialPageParam: undefined,
|
initialPageParam: undefined,
|
||||||
@@ -54,7 +53,7 @@ export function useStarterPackSearch({
|
|||||||
}
|
}
|
||||||
|
|
||||||
function select(
|
function select(
|
||||||
data: InfiniteData<AppBskyGraphSearchStarterPacksV2.OutputSchema>,
|
data: InfiniteData<app.bsky.graph.searchStarterPacksV2.$OutputBody>,
|
||||||
) {
|
) {
|
||||||
// enforce uniqueness
|
// enforce uniqueness
|
||||||
const uris = new Set()
|
const uris = new Set()
|
||||||
|
|||||||
@@ -7,14 +7,15 @@ import {
|
|||||||
import {getContentLanguages} from '#/state/preferences/languages'
|
import {getContentLanguages} from '#/state/preferences/languages'
|
||||||
import {STALE} from '#/state/queries'
|
import {STALE} from '#/state/queries'
|
||||||
import {usePreferencesQuery} from '#/state/queries/preferences'
|
import {usePreferencesQuery} from '#/state/queries/preferences'
|
||||||
import {useAgent} from '#/state/session'
|
import {useAppviewClient} from '#/state/session'
|
||||||
|
import {app} from '#/lexicons'
|
||||||
|
|
||||||
export const DEFAULT_LIMIT = 15
|
export const DEFAULT_LIMIT = 15
|
||||||
|
|
||||||
export const createGetSuggestedFeedsQueryKey = () => ['suggested-feeds']
|
export const createGetSuggestedFeedsQueryKey = () => ['suggested-feeds']
|
||||||
|
|
||||||
export function useGetSuggestedFeedsQuery({enabled}: {enabled?: boolean}) {
|
export function useGetSuggestedFeedsQuery({enabled}: {enabled?: boolean}) {
|
||||||
const agent = useAgent()
|
const client = useAppviewClient()
|
||||||
const {data: preferences} = usePreferencesQuery()
|
const {data: preferences} = usePreferencesQuery()
|
||||||
const savedFeeds = preferences?.savedFeeds
|
const savedFeeds = preferences?.savedFeeds
|
||||||
|
|
||||||
@@ -24,7 +25,8 @@ export function useGetSuggestedFeedsQuery({enabled}: {enabled?: boolean}) {
|
|||||||
queryKey: createGetSuggestedFeedsQueryKey(),
|
queryKey: createGetSuggestedFeedsQueryKey(),
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const contentLangs = getContentLanguages().join(',')
|
const contentLangs = getContentLanguages().join(',')
|
||||||
const {data} = await agent.app.bsky.unspecced.getSuggestedFeeds(
|
const data = await client.call(
|
||||||
|
app.bsky.unspecced.getSuggestedFeeds,
|
||||||
{
|
{
|
||||||
limit: DEFAULT_LIMIT,
|
limit: DEFAULT_LIMIT,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,7 +1,3 @@
|
|||||||
import {
|
|
||||||
type AppBskyActorDefs,
|
|
||||||
type AppBskyUnspeccedGetSuggestedOnboardingUsers,
|
|
||||||
} from '@atproto/api'
|
|
||||||
import {type QueryClient, useQuery} from '@tanstack/react-query'
|
import {type QueryClient, useQuery} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {createBskyTopicsHeader} from '#/lib/api/feed/utils'
|
import {createBskyTopicsHeader} from '#/lib/api/feed/utils'
|
||||||
@@ -9,7 +5,8 @@ import {logger} from '#/logger'
|
|||||||
import {getContentLanguages} from '#/state/preferences/languages'
|
import {getContentLanguages} from '#/state/preferences/languages'
|
||||||
import {STALE} from '#/state/queries'
|
import {STALE} from '#/state/queries'
|
||||||
import {usePreferencesQuery} from '#/state/queries/preferences'
|
import {usePreferencesQuery} from '#/state/queries/preferences'
|
||||||
import {useAgent} from '#/state/session'
|
import {useAppviewClient} from '#/state/session'
|
||||||
|
import {app} from '#/lexicons'
|
||||||
|
|
||||||
export type QueryProps = {
|
export type QueryProps = {
|
||||||
category?: string | null
|
category?: string | null
|
||||||
@@ -30,7 +27,7 @@ export const createGetSuggestedOnboardingUsersQueryKey = (
|
|||||||
]
|
]
|
||||||
|
|
||||||
export function useGetSuggestedOnboardingUsersQuery(props: QueryProps) {
|
export function useGetSuggestedOnboardingUsersQuery(props: QueryProps) {
|
||||||
const agent = useAgent()
|
const client = useAppviewClient()
|
||||||
const {data: preferences} = usePreferencesQuery()
|
const {data: preferences} = usePreferencesQuery()
|
||||||
|
|
||||||
return useQuery({
|
return useQuery({
|
||||||
@@ -42,7 +39,8 @@ export function useGetSuggestedOnboardingUsersQuery(props: QueryProps) {
|
|||||||
|
|
||||||
const overrideInterests = props.overrideInterests.join(',')
|
const overrideInterests = props.overrideInterests.join(',')
|
||||||
|
|
||||||
const {data} = await agent.app.bsky.unspecced.getSuggestedOnboardingUsers(
|
const data = await client.call(
|
||||||
|
app.bsky.unspecced.getSuggestedOnboardingUsers,
|
||||||
{
|
{
|
||||||
category: props.category ?? undefined,
|
category: props.category ?? undefined,
|
||||||
limit: props.limit || 10,
|
limit: props.limit || 10,
|
||||||
@@ -66,9 +64,9 @@ export function useGetSuggestedOnboardingUsersQuery(props: QueryProps) {
|
|||||||
export function* findAllProfilesInQueryData(
|
export function* findAllProfilesInQueryData(
|
||||||
queryClient: QueryClient,
|
queryClient: QueryClient,
|
||||||
did: string,
|
did: string,
|
||||||
): Generator<AppBskyActorDefs.ProfileView, void> {
|
): Generator<app.bsky.actor.defs.ProfileView, void> {
|
||||||
const responses =
|
const responses =
|
||||||
queryClient.getQueriesData<AppBskyUnspeccedGetSuggestedOnboardingUsers.OutputSchema>(
|
queryClient.getQueriesData<app.bsky.unspecced.getSuggestedOnboardingUsers.$OutputBody>(
|
||||||
{
|
{
|
||||||
queryKey: [getSuggestedOnboardingUsersQueryKeyRoot],
|
queryKey: [getSuggestedOnboardingUsersQueryKeyRoot],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,7 +1,3 @@
|
|||||||
import {
|
|
||||||
type AppBskyActorDefs,
|
|
||||||
type AppBskyUnspeccedGetSuggestedUsersForDiscover,
|
|
||||||
} from '@atproto/api'
|
|
||||||
import {type QueryClient, useQuery} from '@tanstack/react-query'
|
import {type QueryClient, useQuery} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -12,7 +8,8 @@ import {logger} from '#/logger'
|
|||||||
import {getContentLanguages} from '#/state/preferences/languages'
|
import {getContentLanguages} from '#/state/preferences/languages'
|
||||||
import {STALE} from '#/state/queries'
|
import {STALE} from '#/state/queries'
|
||||||
import {usePreferencesQuery} from '#/state/queries/preferences'
|
import {usePreferencesQuery} from '#/state/queries/preferences'
|
||||||
import {useAgent} from '#/state/session'
|
import {useAppviewClient} from '#/state/session'
|
||||||
|
import {app} from '#/lexicons'
|
||||||
|
|
||||||
export type QueryProps = {
|
export type QueryProps = {
|
||||||
limit?: number
|
limit?: number
|
||||||
@@ -25,7 +22,7 @@ export const createGetSuggestedUsersForDiscoverQueryKey = (props: {
|
|||||||
}) => [getSuggestedUsersForDiscoverQueryKeyRoot, props.limit]
|
}) => [getSuggestedUsersForDiscoverQueryKeyRoot, props.limit]
|
||||||
|
|
||||||
export function useGetSuggestedUsersForDiscoverQuery(props: QueryProps = {}) {
|
export function useGetSuggestedUsersForDiscoverQuery(props: QueryProps = {}) {
|
||||||
const agent = useAgent()
|
const client = useAppviewClient()
|
||||||
const {data: preferences} = usePreferencesQuery()
|
const {data: preferences} = usePreferencesQuery()
|
||||||
|
|
||||||
return useQuery({
|
return useQuery({
|
||||||
@@ -35,18 +32,18 @@ export function useGetSuggestedUsersForDiscoverQuery(props: QueryProps = {}) {
|
|||||||
const contentLangs = getContentLanguages().join(',')
|
const contentLangs = getContentLanguages().join(',')
|
||||||
const userInterests = aggregateUserInterests(preferences)
|
const userInterests = aggregateUserInterests(preferences)
|
||||||
|
|
||||||
const {data} =
|
const data = await client.call(
|
||||||
await agent.app.bsky.unspecced.getSuggestedUsersForDiscover(
|
app.bsky.unspecced.getSuggestedUsersForDiscover,
|
||||||
{
|
{
|
||||||
limit: props.limit || 10,
|
limit: props.limit || 10,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
...createBskyTopicsHeader(userInterests),
|
||||||
|
'Accept-Language': contentLangs,
|
||||||
},
|
},
|
||||||
{
|
},
|
||||||
headers: {
|
)
|
||||||
...createBskyTopicsHeader(userInterests),
|
|
||||||
'Accept-Language': contentLangs,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
)
|
|
||||||
if (!data.recIdStr) {
|
if (!data.recIdStr) {
|
||||||
logger.debug('getSuggestedUsersForDiscover response missing recIdStr')
|
logger.debug('getSuggestedUsersForDiscover response missing recIdStr')
|
||||||
}
|
}
|
||||||
@@ -58,9 +55,9 @@ export function useGetSuggestedUsersForDiscoverQuery(props: QueryProps = {}) {
|
|||||||
export function* findAllProfilesInQueryData(
|
export function* findAllProfilesInQueryData(
|
||||||
queryClient: QueryClient,
|
queryClient: QueryClient,
|
||||||
did: string,
|
did: string,
|
||||||
): Generator<AppBskyActorDefs.ProfileView, void> {
|
): Generator<app.bsky.actor.defs.ProfileView, void> {
|
||||||
const responses =
|
const responses =
|
||||||
queryClient.getQueriesData<AppBskyUnspeccedGetSuggestedUsersForDiscover.OutputSchema>(
|
queryClient.getQueriesData<app.bsky.unspecced.getSuggestedUsersForDiscover.$OutputBody>(
|
||||||
{
|
{
|
||||||
queryKey: [getSuggestedUsersForDiscoverQueryKeyRoot],
|
queryKey: [getSuggestedUsersForDiscoverQueryKeyRoot],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,7 +1,3 @@
|
|||||||
import {
|
|
||||||
type AppBskyActorDefs,
|
|
||||||
type AppBskyUnspeccedGetSuggestedUsersForExplore,
|
|
||||||
} from '@atproto/api'
|
|
||||||
import {type QueryClient, useQuery} from '@tanstack/react-query'
|
import {type QueryClient, useQuery} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -12,7 +8,8 @@ import {logger} from '#/logger'
|
|||||||
import {getContentLanguages} from '#/state/preferences/languages'
|
import {getContentLanguages} from '#/state/preferences/languages'
|
||||||
import {STALE} from '#/state/queries'
|
import {STALE} from '#/state/queries'
|
||||||
import {usePreferencesQuery} from '#/state/queries/preferences'
|
import {usePreferencesQuery} from '#/state/queries/preferences'
|
||||||
import {useAgent} from '#/state/session'
|
import {useAppviewClient} from '#/state/session'
|
||||||
|
import {app} from '#/lexicons'
|
||||||
|
|
||||||
export type QueryProps = {
|
export type QueryProps = {
|
||||||
category?: string | null
|
category?: string | null
|
||||||
@@ -26,7 +23,7 @@ export const createGetSuggestedUsersForExploreQueryKey = (
|
|||||||
) => [getSuggestedUsersForExploreQueryKeyRoot, props.category, props.limit]
|
) => [getSuggestedUsersForExploreQueryKeyRoot, props.category, props.limit]
|
||||||
|
|
||||||
export function useGetSuggestedUsersForExploreQuery(props: QueryProps = {}) {
|
export function useGetSuggestedUsersForExploreQuery(props: QueryProps = {}) {
|
||||||
const agent = useAgent()
|
const client = useAppviewClient()
|
||||||
const {data: preferences} = usePreferencesQuery()
|
const {data: preferences} = usePreferencesQuery()
|
||||||
|
|
||||||
return useQuery({
|
return useQuery({
|
||||||
@@ -36,7 +33,8 @@ export function useGetSuggestedUsersForExploreQuery(props: QueryProps = {}) {
|
|||||||
const contentLangs = getContentLanguages().join(',')
|
const contentLangs = getContentLanguages().join(',')
|
||||||
const userInterests = aggregateUserInterests(preferences)
|
const userInterests = aggregateUserInterests(preferences)
|
||||||
|
|
||||||
const {data} = await agent.app.bsky.unspecced.getSuggestedUsersForExplore(
|
const data = await client.call(
|
||||||
|
app.bsky.unspecced.getSuggestedUsersForExplore,
|
||||||
{
|
{
|
||||||
category: props.category ?? undefined,
|
category: props.category ?? undefined,
|
||||||
limit: props.limit || 10,
|
limit: props.limit || 10,
|
||||||
@@ -60,9 +58,9 @@ export function useGetSuggestedUsersForExploreQuery(props: QueryProps = {}) {
|
|||||||
export function* findAllProfilesInQueryData(
|
export function* findAllProfilesInQueryData(
|
||||||
queryClient: QueryClient,
|
queryClient: QueryClient,
|
||||||
did: string,
|
did: string,
|
||||||
): Generator<AppBskyActorDefs.ProfileView, void> {
|
): Generator<app.bsky.actor.defs.ProfileView, void> {
|
||||||
const responses =
|
const responses =
|
||||||
queryClient.getQueriesData<AppBskyUnspeccedGetSuggestedUsersForExplore.OutputSchema>(
|
queryClient.getQueriesData<app.bsky.unspecced.getSuggestedUsersForExplore.$OutputBody>(
|
||||||
{
|
{
|
||||||
queryKey: [getSuggestedUsersForExploreQueryKeyRoot],
|
queryKey: [getSuggestedUsersForExploreQueryKeyRoot],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,7 +1,3 @@
|
|||||||
import {
|
|
||||||
type AppBskyActorDefs,
|
|
||||||
type AppBskyUnspeccedGetSuggestedUsersForSeeMore,
|
|
||||||
} from '@atproto/api'
|
|
||||||
import {type QueryClient, useQuery} from '@tanstack/react-query'
|
import {type QueryClient, useQuery} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -12,7 +8,8 @@ import {logger} from '#/logger'
|
|||||||
import {getContentLanguages} from '#/state/preferences/languages'
|
import {getContentLanguages} from '#/state/preferences/languages'
|
||||||
import {STALE} from '#/state/queries'
|
import {STALE} from '#/state/queries'
|
||||||
import {usePreferencesQuery} from '#/state/queries/preferences'
|
import {usePreferencesQuery} from '#/state/queries/preferences'
|
||||||
import {useAgent} from '#/state/session'
|
import {useAppviewClient} from '#/state/session'
|
||||||
|
import {app} from '#/lexicons'
|
||||||
|
|
||||||
export type QueryProps = {
|
export type QueryProps = {
|
||||||
category?: string | null
|
category?: string | null
|
||||||
@@ -28,7 +25,7 @@ export const createGetSuggestedUsersForSeeMoreQueryKey = (props: {
|
|||||||
}) => [getSuggestedUsersForSeeMoreQueryKeyRoot, props.category, props.limit]
|
}) => [getSuggestedUsersForSeeMoreQueryKeyRoot, props.category, props.limit]
|
||||||
|
|
||||||
export function useGetSuggestedUsersForSeeMoreQuery(props: QueryProps = {}) {
|
export function useGetSuggestedUsersForSeeMoreQuery(props: QueryProps = {}) {
|
||||||
const agent = useAgent()
|
const client = useAppviewClient()
|
||||||
const {data: preferences} = usePreferencesQuery()
|
const {data: preferences} = usePreferencesQuery()
|
||||||
|
|
||||||
return useQuery({
|
return useQuery({
|
||||||
@@ -42,7 +39,8 @@ export function useGetSuggestedUsersForSeeMoreQuery(props: QueryProps = {}) {
|
|||||||
const contentLangs = getContentLanguages().join(',')
|
const contentLangs = getContentLanguages().join(',')
|
||||||
const userInterests = aggregateUserInterests(preferences)
|
const userInterests = aggregateUserInterests(preferences)
|
||||||
|
|
||||||
const {data} = await agent.app.bsky.unspecced.getSuggestedUsersForSeeMore(
|
const data = await client.call(
|
||||||
|
app.bsky.unspecced.getSuggestedUsersForSeeMore,
|
||||||
{
|
{
|
||||||
category: props.category ?? undefined,
|
category: props.category ?? undefined,
|
||||||
limit: props.limit || 50,
|
limit: props.limit || 50,
|
||||||
@@ -66,9 +64,9 @@ export function useGetSuggestedUsersForSeeMoreQuery(props: QueryProps = {}) {
|
|||||||
export function* findAllProfilesInQueryData(
|
export function* findAllProfilesInQueryData(
|
||||||
queryClient: QueryClient,
|
queryClient: QueryClient,
|
||||||
did: string,
|
did: string,
|
||||||
): Generator<AppBskyActorDefs.ProfileView, void> {
|
): Generator<app.bsky.actor.defs.ProfileView, void> {
|
||||||
const responses =
|
const responses =
|
||||||
queryClient.getQueriesData<AppBskyUnspeccedGetSuggestedUsersForSeeMore.OutputSchema>(
|
queryClient.getQueriesData<app.bsky.unspecced.getSuggestedUsersForSeeMore.$OutputBody>(
|
||||||
{
|
{
|
||||||
queryKey: [getSuggestedUsersForSeeMoreQueryKeyRoot],
|
queryKey: [getSuggestedUsersForSeeMoreQueryKeyRoot],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ import {
|
|||||||
import {getContentLanguages} from '#/state/preferences/languages'
|
import {getContentLanguages} from '#/state/preferences/languages'
|
||||||
import {STALE} from '#/state/queries'
|
import {STALE} from '#/state/queries'
|
||||||
import {usePreferencesQuery} from '#/state/queries/preferences'
|
import {usePreferencesQuery} from '#/state/queries/preferences'
|
||||||
import {useAgent} from '#/state/session'
|
import {useAppviewClient} from '#/state/session'
|
||||||
|
import {app} from '#/lexicons'
|
||||||
|
|
||||||
export const createOnboardingSuggestedStarterPacksQueryKey = (
|
export const createOnboardingSuggestedStarterPacksQueryKey = (
|
||||||
interests?: string[],
|
interests?: string[],
|
||||||
@@ -20,7 +21,7 @@ export function useOnboardingSuggestedStarterPacksQuery({
|
|||||||
enabled?: boolean
|
enabled?: boolean
|
||||||
overrideInterests?: string[]
|
overrideInterests?: string[]
|
||||||
}) {
|
}) {
|
||||||
const agent = useAgent()
|
const client = useAppviewClient()
|
||||||
const {data: preferences} = usePreferencesQuery()
|
const {data: preferences} = usePreferencesQuery()
|
||||||
const contentLangs = getContentLanguages().join(',')
|
const contentLangs = getContentLanguages().join(',')
|
||||||
|
|
||||||
@@ -29,21 +30,20 @@ export function useOnboardingSuggestedStarterPacksQuery({
|
|||||||
staleTime: STALE.MINUTES.THREE,
|
staleTime: STALE.MINUTES.THREE,
|
||||||
queryKey: createOnboardingSuggestedStarterPacksQueryKey(overrideInterests),
|
queryKey: createOnboardingSuggestedStarterPacksQueryKey(overrideInterests),
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const {data} =
|
return await client.call(
|
||||||
await agent.app.bsky.unspecced.getOnboardingSuggestedStarterPacks(
|
app.bsky.unspecced.getOnboardingSuggestedStarterPacks,
|
||||||
{limit: 6},
|
{limit: 6},
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
...createBskyTopicsHeader(
|
...createBskyTopicsHeader(
|
||||||
overrideInterests
|
overrideInterests
|
||||||
? overrideInterests.join(',')
|
? overrideInterests.join(',')
|
||||||
: aggregateUserInterests(preferences),
|
: aggregateUserInterests(preferences),
|
||||||
),
|
),
|
||||||
'Accept-Language': contentLangs,
|
'Accept-Language': contentLangs,
|
||||||
},
|
|
||||||
},
|
},
|
||||||
)
|
},
|
||||||
return data
|
)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import {useCallback, useMemo, useState} from 'react'
|
import {useCallback, useMemo, useState} from 'react'
|
||||||
|
import {type AtUriString} from '@atproto/syntax'
|
||||||
import {useQuery, useQueryClient} from '@tanstack/react-query'
|
import {useQuery, useQueryClient} from '@tanstack/react-query'
|
||||||
|
|
||||||
import {useModerationOpts} from '#/state/preferences/moderation-opts'
|
import {useModerationOpts} from '#/state/preferences/moderation-opts'
|
||||||
@@ -27,10 +28,11 @@ import {
|
|||||||
} from '#/state/queries/usePostThread/types'
|
} from '#/state/queries/usePostThread/types'
|
||||||
import {getThreadgateRecord} from '#/state/queries/usePostThread/utils'
|
import {getThreadgateRecord} from '#/state/queries/usePostThread/utils'
|
||||||
import * as views from '#/state/queries/usePostThread/views'
|
import * as views from '#/state/queries/usePostThread/views'
|
||||||
import {useAgent, useSession} from '#/state/session'
|
import {useAppviewClient, useSession} from '#/state/session'
|
||||||
import {useMergeThreadgateHiddenReplies} from '#/state/threadgate-hidden-replies'
|
import {useMergeThreadgateHiddenReplies} from '#/state/threadgate-hidden-replies'
|
||||||
import {useBreakpoints} from '#/alf'
|
import {useBreakpoints} from '#/alf'
|
||||||
import {IS_WEB} from '#/env'
|
import {IS_WEB} from '#/env'
|
||||||
|
import {app} from '#/lexicons'
|
||||||
|
|
||||||
export * from '#/state/queries/usePostThread/context'
|
export * from '#/state/queries/usePostThread/context'
|
||||||
export {useUpdatePostThreadThreadgateQueryCache} from '#/state/queries/usePostThread/queryCache'
|
export {useUpdatePostThreadThreadgateQueryCache} from '#/state/queries/usePostThread/queryCache'
|
||||||
@@ -38,7 +40,7 @@ export * from '#/state/queries/usePostThread/types'
|
|||||||
|
|
||||||
export function usePostThread({anchor}: {anchor?: string}) {
|
export function usePostThread({anchor}: {anchor?: string}) {
|
||||||
const qc = useQueryClient()
|
const qc = useQueryClient()
|
||||||
const agent = useAgent()
|
const client = useAppviewClient()
|
||||||
const {hasSession} = useSession()
|
const {hasSession} = useSession()
|
||||||
const {gtPhone} = useBreakpoints()
|
const {gtPhone} = useBreakpoints()
|
||||||
const moderationOpts = useModerationOpts()
|
const moderationOpts = useModerationOpts()
|
||||||
@@ -71,8 +73,8 @@ export function usePostThread({anchor}: {anchor?: string}) {
|
|||||||
enabled: isThreadPreferencesLoaded && !!anchor && !!moderationOpts,
|
enabled: isThreadPreferencesLoaded && !!anchor && !!moderationOpts,
|
||||||
queryKey: postThreadQueryKey,
|
queryKey: postThreadQueryKey,
|
||||||
async queryFn(ctx) {
|
async queryFn(ctx) {
|
||||||
const {data} = await agent.app.bsky.unspecced.getPostThreadV2({
|
const data = await client.call(app.bsky.unspecced.getPostThreadV2, {
|
||||||
anchor: anchor!,
|
anchor: anchor! as AtUriString,
|
||||||
branchingFactor: view === 'linear' ? LINEAR_VIEW_BF : TREE_VIEW_BF,
|
branchingFactor: view === 'linear' ? LINEAR_VIEW_BF : TREE_VIEW_BF,
|
||||||
below,
|
below,
|
||||||
sort: sort,
|
sort: sort,
|
||||||
@@ -93,18 +95,24 @@ export function usePostThread({anchor}: {anchor?: string}) {
|
|||||||
ctx.meta.hasOtherReplies = true
|
ctx.meta.hasOtherReplies = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The generated views type `threadgate.record` as an opaque lex map and
|
||||||
|
* brand at-uris, so the response is asserted to the exported result type
|
||||||
|
* here; the record swap-in below and every downstream consumer of the
|
||||||
|
* thread read that narrower contract.
|
||||||
|
*/
|
||||||
const result = {
|
const result = {
|
||||||
thread: data.thread || [],
|
thread: data.thread || [],
|
||||||
threadgate: data.threadgate,
|
threadgate: data.threadgate,
|
||||||
hasOtherReplies: !!ctx.meta.hasOtherReplies,
|
hasOtherReplies: !!ctx.meta.hasOtherReplies,
|
||||||
}
|
} as UsePostThreadQueryResult
|
||||||
|
|
||||||
const record = getThreadgateRecord(result.threadgate)
|
const record = getThreadgateRecord(result.threadgate)
|
||||||
if (result.threadgate && record) {
|
if (result.threadgate && record) {
|
||||||
result.threadgate.record = record
|
result.threadgate.record = record
|
||||||
}
|
}
|
||||||
|
|
||||||
return result as UsePostThreadQueryResult
|
return result
|
||||||
},
|
},
|
||||||
placeholderData() {
|
placeholderData() {
|
||||||
if (!anchor) return
|
if (!anchor) return
|
||||||
@@ -161,10 +169,9 @@ export function usePostThread({anchor}: {anchor?: string}) {
|
|||||||
enabled: additionalQueryEnabled,
|
enabled: additionalQueryEnabled,
|
||||||
queryKey: postThreadOtherQueryKey,
|
queryKey: postThreadOtherQueryKey,
|
||||||
async queryFn() {
|
async queryFn() {
|
||||||
const {data} = await agent.app.bsky.unspecced.getPostThreadOtherV2({
|
return await client.call(app.bsky.unspecced.getPostThreadOtherV2, {
|
||||||
anchor: anchor!,
|
anchor: anchor! as AtUriString,
|
||||||
})
|
})
|
||||||
return data
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
const serverOtherThreadItems: ThreadItem[] = useMemo(() => {
|
const serverOtherThreadItems: ThreadItem[] = useMemo(() => {
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ import {
|
|||||||
import {getContentLanguages} from '#/state/preferences/languages'
|
import {getContentLanguages} from '#/state/preferences/languages'
|
||||||
import {STALE} from '#/state/queries'
|
import {STALE} from '#/state/queries'
|
||||||
import {usePreferencesQuery} from '#/state/queries/preferences'
|
import {usePreferencesQuery} from '#/state/queries/preferences'
|
||||||
import {useAgent} from '#/state/session'
|
import {useAppviewClient} from '#/state/session'
|
||||||
|
import {app} from '#/lexicons'
|
||||||
|
|
||||||
export const createSuggestedStarterPacksQueryKey = (interests?: string[]) => [
|
export const createSuggestedStarterPacksQueryKey = (interests?: string[]) => [
|
||||||
'suggested-starter-packs',
|
'suggested-starter-packs',
|
||||||
@@ -21,7 +22,7 @@ export function useSuggestedStarterPacksQuery({
|
|||||||
enabled?: boolean
|
enabled?: boolean
|
||||||
overrideInterests?: string[]
|
overrideInterests?: string[]
|
||||||
}) {
|
}) {
|
||||||
const agent = useAgent()
|
const client = useAppviewClient()
|
||||||
const {data: preferences} = usePreferencesQuery()
|
const {data: preferences} = usePreferencesQuery()
|
||||||
const contentLangs = getContentLanguages().join(',')
|
const contentLangs = getContentLanguages().join(',')
|
||||||
|
|
||||||
@@ -30,8 +31,9 @@ export function useSuggestedStarterPacksQuery({
|
|||||||
staleTime: STALE.MINUTES.THREE,
|
staleTime: STALE.MINUTES.THREE,
|
||||||
queryKey: createSuggestedStarterPacksQueryKey(overrideInterests),
|
queryKey: createSuggestedStarterPacksQueryKey(overrideInterests),
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const {data} = await agent.app.bsky.unspecced.getSuggestedStarterPacks(
|
return await client.call(
|
||||||
undefined,
|
app.bsky.unspecced.getSuggestedStarterPacks,
|
||||||
|
{},
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
...createBskyTopicsHeader(
|
...createBskyTopicsHeader(
|
||||||
@@ -43,7 +45,6 @@ export function useSuggestedStarterPacksQuery({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
return data
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,12 +47,12 @@ import {type ImagePickerAsset} from 'expo-image-picker'
|
|||||||
import {
|
import {
|
||||||
AppBskyDraftCreateDraft,
|
AppBskyDraftCreateDraft,
|
||||||
AppBskyUnspeccedDefs,
|
AppBskyUnspeccedDefs,
|
||||||
type AppBskyUnspeccedGetPostThreadV2,
|
|
||||||
type AtpAgent,
|
|
||||||
AtUri,
|
AtUri,
|
||||||
ChatBskyGroupDefs,
|
ChatBskyGroupDefs,
|
||||||
type RichText,
|
type RichText,
|
||||||
} from '@atproto/api'
|
} from '@atproto/api'
|
||||||
|
import {type Client} from '@atproto/lex'
|
||||||
|
import {type AtUriString} from '@atproto/syntax'
|
||||||
import {plural} from '@lingui/core/macro'
|
import {plural} from '@lingui/core/macro'
|
||||||
import {Trans, useLingui} from '@lingui/react/macro'
|
import {Trans, useLingui} from '@lingui/react/macro'
|
||||||
import {useNavigation} from '@react-navigation/native'
|
import {useNavigation} from '@react-navigation/native'
|
||||||
@@ -96,7 +96,7 @@ import {
|
|||||||
import {usePreferencesQuery} from '#/state/queries/preferences'
|
import {usePreferencesQuery} from '#/state/queries/preferences'
|
||||||
import {useProfileQuery} from '#/state/queries/profile'
|
import {useProfileQuery} from '#/state/queries/profile'
|
||||||
import {resolveLinkQueryOptions} from '#/state/queries/resolve-link'
|
import {resolveLinkQueryOptions} from '#/state/queries/resolve-link'
|
||||||
import {useAgent, useSession} from '#/state/session'
|
import {useAgent, useAppviewClient, useSession} from '#/state/session'
|
||||||
import {useComposerControls} from '#/state/shell/composer'
|
import {useComposerControls} from '#/state/shell/composer'
|
||||||
import {type ComposerOpts, type OnPostSuccessData} from '#/state/shell/composer'
|
import {type ComposerOpts, type OnPostSuccessData} from '#/state/shell/composer'
|
||||||
import {CharProgress} from '#/view/com/composer/char-progress/CharProgress'
|
import {CharProgress} from '#/view/com/composer/char-progress/CharProgress'
|
||||||
@@ -144,6 +144,7 @@ import {
|
|||||||
IS_WEB_SAFARI,
|
IS_WEB_SAFARI,
|
||||||
} from '#/env'
|
} from '#/env'
|
||||||
import {type Gif} from '#/features/gifPicker/types'
|
import {type Gif} from '#/features/gifPicker/types'
|
||||||
|
import {app} from '#/lexicons'
|
||||||
import {BottomSheetPortalProvider} from '../../../../modules/bottom-sheet'
|
import {BottomSheetPortalProvider} from '../../../../modules/bottom-sheet'
|
||||||
import {
|
import {
|
||||||
draftToComposerPosts,
|
draftToComposerPosts,
|
||||||
@@ -275,6 +276,7 @@ export const ComposePost = ({
|
|||||||
? VIDEO_10_MINUTE_MAX_DURATION_MS
|
? VIDEO_10_MINUTE_MAX_DURATION_MS
|
||||||
: VIDEO_MAX_DURATION_MS
|
: VIDEO_MAX_DURATION_MS
|
||||||
const agent = useAgent()
|
const agent = useAgent()
|
||||||
|
const client = useAppviewClient()
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
const currentDid = currentAccount!.did
|
const currentDid = currentAccount!.did
|
||||||
const {closeComposer} = useComposerControls()
|
const {closeComposer} = useComposerControls()
|
||||||
@@ -1105,23 +1107,26 @@ export const ComposePost = ({
|
|||||||
5,
|
5,
|
||||||
_e => true,
|
_e => true,
|
||||||
async () => {
|
async () => {
|
||||||
const res = await agent.app.bsky.unspecced.getPostThreadV2({
|
const res = await client.call(
|
||||||
anchor: postUri!,
|
app.bsky.unspecced.getPostThreadV2,
|
||||||
above: false,
|
{
|
||||||
below: filteredThread.posts.length - 1,
|
anchor: postUri! as AtUriString,
|
||||||
branchingFactor: 1,
|
above: false,
|
||||||
})
|
below: filteredThread.posts.length - 1,
|
||||||
if (res.data.thread.length !== filteredThread.posts.length) {
|
branchingFactor: 1,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
if (res.thread.length !== filteredThread.posts.length) {
|
||||||
throw new Error(`composer: app view is not ready`)
|
throw new Error(`composer: app view is not ready`)
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
!res.data.thread.every(p =>
|
!res.thread.every(p =>
|
||||||
AppBskyUnspeccedDefs.isThreadItemPost(p.value),
|
AppBskyUnspeccedDefs.isThreadItemPost(p.value),
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
throw new Error(`composer: app view returned non-post items`)
|
throw new Error(`composer: app view returned non-post items`)
|
||||||
}
|
}
|
||||||
return res.data.thread
|
return res.thread
|
||||||
},
|
},
|
||||||
1e3,
|
1e3,
|
||||||
)
|
)
|
||||||
@@ -1224,8 +1229,8 @@ export const ComposePost = ({
|
|||||||
setLangPrefs.savePostLanguageToHistory()
|
setLangPrefs.savePostLanguageToHistory()
|
||||||
if (initQuote) {
|
if (initQuote) {
|
||||||
// We want to wait for the quote count to update before we call `onPost`, which will refetch data
|
// We want to wait for the quote count to update before we call `onPost`, which will refetch data
|
||||||
void whenAppViewReady(agent, initQuote.uri, res => {
|
void whenAppViewReady(client, initQuote.uri, res => {
|
||||||
const anchor = res.data.thread.at(0)
|
const anchor = res.thread.at(0)
|
||||||
if (
|
if (
|
||||||
AppBskyUnspeccedDefs.isThreadItemPost(anchor?.value) &&
|
AppBskyUnspeccedDefs.isThreadItemPost(anchor?.value) &&
|
||||||
anchor.value.post.quoteCount !== initQuote.quoteCount
|
anchor.value.post.quoteCount !== initQuote.quoteCount
|
||||||
@@ -1272,6 +1277,7 @@ export const ComposePost = ({
|
|||||||
l,
|
l,
|
||||||
ax,
|
ax,
|
||||||
agent,
|
agent,
|
||||||
|
client,
|
||||||
canPost,
|
canPost,
|
||||||
isPublishing,
|
isPublishing,
|
||||||
currentLanguages,
|
currentLanguages,
|
||||||
@@ -2486,17 +2492,17 @@ function useKeyboardVerticalOffset() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function whenAppViewReady(
|
async function whenAppViewReady(
|
||||||
agent: AtpAgent,
|
client: Client,
|
||||||
uri: string,
|
uri: string,
|
||||||
fn: (res: AppBskyUnspeccedGetPostThreadV2.Response) => boolean,
|
fn: (res: app.bsky.unspecced.getPostThreadV2.$OutputBody) => boolean,
|
||||||
) {
|
) {
|
||||||
await until(
|
await until(
|
||||||
5, // 5 tries
|
5, // 5 tries
|
||||||
1e3, // 1s delay between tries
|
1e3, // 1s delay between tries
|
||||||
fn,
|
fn,
|
||||||
() =>
|
() =>
|
||||||
agent.app.bsky.unspecced.getPostThreadV2({
|
client.call(app.bsky.unspecced.getPostThreadV2, {
|
||||||
anchor: uri,
|
anchor: uri as AtUriString,
|
||||||
above: false,
|
above: false,
|
||||||
below: 0,
|
below: 0,
|
||||||
branchingFactor: 0,
|
branchingFactor: 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user