cast branded params with the dedicated syntax types
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import {type DidString} from '@atproto/syntax'
|
||||
import {type QueryClient, useInfiniteQuery} from '@tanstack/react-query'
|
||||
|
||||
import {useAppviewClient} from '#/state/session'
|
||||
@@ -25,7 +26,7 @@ export function useActorStarterPacksQuery({
|
||||
queryFn: async ({pageParam}: {pageParam?: string}) => {
|
||||
return await client.call(app.bsky.graph.getActorStarterPacks, {
|
||||
// the enabled flag prevents this from running until did is set
|
||||
actor: did! as app.bsky.graph.getActorStarterPacks.$Params['actor'],
|
||||
actor: did! as DidString,
|
||||
limit: 10,
|
||||
cursor: pageParam,
|
||||
})
|
||||
@@ -50,8 +51,7 @@ export function useActorStarterPacksWithMembershipsQuery({
|
||||
queryFn: async ({pageParam}: {pageParam?: string}) => {
|
||||
return await client.call(app.bsky.graph.getStarterPacksWithMembership, {
|
||||
// the enabled flag prevents this from running until did is set
|
||||
actor:
|
||||
did! as app.bsky.graph.getStarterPacksWithMembership.$Params['actor'],
|
||||
actor: did! as DidString,
|
||||
limit: 10,
|
||||
cursor: pageParam,
|
||||
})
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {type AppBskyActorDefs} from '@atproto/api'
|
||||
import {type DidString} from '@atproto/syntax'
|
||||
import {
|
||||
type InfiniteData,
|
||||
type QueryClient,
|
||||
@@ -28,7 +29,7 @@ export function useProfileKnownFollowersQuery(did: string | undefined) {
|
||||
async queryFn({pageParam}: {pageParam: RQPageParam}) {
|
||||
return await client.call(app.bsky.graph.getKnownFollowers, {
|
||||
// the enabled flag prevents this from running until did is set
|
||||
actor: did! as app.bsky.graph.getKnownFollowers.$Params['actor'],
|
||||
actor: did! as DidString,
|
||||
limit: PAGE_SIZE,
|
||||
cursor: pageParam,
|
||||
})
|
||||
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
type AppBskyGraphDefs,
|
||||
type AtpAgent,
|
||||
} from '@atproto/api'
|
||||
import {type AtUriString} from '@atproto/syntax'
|
||||
import {
|
||||
type InfiniteData,
|
||||
type QueryClient,
|
||||
@@ -37,7 +38,7 @@ export function useListMembersQuery(uri?: string, limit: number = PAGE_SIZE) {
|
||||
async queryFn({pageParam}: {pageParam: RQPageParam}) {
|
||||
return await client.call(app.bsky.graph.getList, {
|
||||
// the enabled flag will prevent this from running until uri is set
|
||||
list: uri! as app.bsky.graph.getList.$Params['list'],
|
||||
list: uri! as AtUriString,
|
||||
limit,
|
||||
cursor: pageParam,
|
||||
})
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {type AppBskyActorDefs} from '@atproto/api'
|
||||
import {type AtIdentifierString} from '@atproto/syntax'
|
||||
import {
|
||||
type InfiniteData,
|
||||
type QueryClient,
|
||||
@@ -37,7 +38,7 @@ export function useListsWithMembershipQuery({
|
||||
queryFn: async ({pageParam}: {pageParam?: string}) => {
|
||||
return await client.call(app.bsky.graph.getListsWithMembership, {
|
||||
// the enabled flag prevents this from running until actor is set
|
||||
actor: actor! as app.bsky.graph.getListsWithMembership.$Params['actor'],
|
||||
actor: actor! as AtIdentifierString,
|
||||
limit: 50,
|
||||
cursor: pageParam,
|
||||
})
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {type AppBskyGraphDefs} from '@atproto/api'
|
||||
import {type DidString} from '@atproto/syntax'
|
||||
import {type QueryClient, useQuery} from '@tanstack/react-query'
|
||||
|
||||
import {accumulate} from '#/lib/async/accumulate'
|
||||
@@ -27,8 +28,7 @@ export function useMyListsQuery(filter: MyListsFilter) {
|
||||
accumulate(cursor =>
|
||||
client
|
||||
.call(app.bsky.graph.getLists, {
|
||||
actor: currentAccount!
|
||||
.did as app.bsky.graph.getLists.$Params['actor'],
|
||||
actor: currentAccount!.did as DidString,
|
||||
cursor,
|
||||
limit: 50,
|
||||
})
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import {type DidString} from '@atproto/syntax'
|
||||
import {msg} from '@lingui/core/macro'
|
||||
import {useLingui} from '@lingui/react'
|
||||
import {useMutation, useQueryClient} from '@tanstack/react-query'
|
||||
@@ -35,8 +36,7 @@ export function usePinnedPostMutation() {
|
||||
// get the currently pinned post so we can optimistically remove the pin from it
|
||||
if (!currentAccount) throw new Error('Not signed in')
|
||||
const profile = await client.call(app.bsky.actor.getProfile, {
|
||||
actor:
|
||||
currentAccount.did as app.bsky.actor.getProfile.$Params['actor'],
|
||||
actor: currentAccount.did as DidString,
|
||||
})
|
||||
prevPinnedPost = profile.pinnedPost?.uri
|
||||
if (prevPinnedPost && prevPinnedPost !== postUri) {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {moderateFeedGenerator} from '@atproto/api'
|
||||
import {type DidString} from '@atproto/syntax'
|
||||
import {
|
||||
type InfiniteData,
|
||||
type QueryKey,
|
||||
@@ -33,7 +34,7 @@ export function useProfileFeedgensQuery(
|
||||
queryKey: RQKEY(did),
|
||||
async queryFn({pageParam}: {pageParam: RQPageParam}) {
|
||||
const data = await client.call(app.bsky.feed.getActorFeeds, {
|
||||
actor: did as app.bsky.feed.getActorFeeds.$Params['actor'],
|
||||
actor: did as DidString,
|
||||
limit: PAGE_SIZE,
|
||||
cursor: pageParam,
|
||||
})
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {type AppBskyActorDefs} from '@atproto/api'
|
||||
import {type DidString} from '@atproto/syntax'
|
||||
import {
|
||||
type InfiniteData,
|
||||
type QueryClient,
|
||||
@@ -51,7 +52,7 @@ export function useProfileFollowersQuery(
|
||||
* is `undefined`, hence the conditional spread.
|
||||
*/
|
||||
return await client.call(app.bsky.graph.getFollowers, {
|
||||
actor: (did || '') as app.bsky.graph.getFollowers.$Params['actor'],
|
||||
actor: (did || '') as DidString,
|
||||
limit: PAGE_SIZE,
|
||||
cursor: pageParam,
|
||||
...(sortParam ? {sort: sortParam} : {}),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {type AppBskyActorDefs} from '@atproto/api'
|
||||
import {type DidString} from '@atproto/syntax'
|
||||
import {
|
||||
type InfiniteData,
|
||||
type QueryClient,
|
||||
@@ -56,7 +57,7 @@ export function useProfileFollowsQuery(
|
||||
* is `undefined`, hence the conditional spread.
|
||||
*/
|
||||
return await client.call(app.bsky.graph.getFollows, {
|
||||
actor: (did || '') as app.bsky.graph.getFollows.$Params['actor'],
|
||||
actor: (did || '') as DidString,
|
||||
limit: limit || PAGE_SIZE,
|
||||
cursor: pageParam,
|
||||
...(sortParam ? {sort: sortParam} : {}),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {moderateUserList} from '@atproto/api'
|
||||
import {type DidString} from '@atproto/syntax'
|
||||
import {
|
||||
type InfiniteData,
|
||||
type QueryKey,
|
||||
@@ -29,7 +30,7 @@ export function useProfileListsQuery(did: string, opts?: {enabled?: boolean}) {
|
||||
queryKey: RQKEY(did),
|
||||
async queryFn({pageParam}: {pageParam: RQPageParam}) {
|
||||
return await client.call(app.bsky.graph.getLists, {
|
||||
actor: did as app.bsky.graph.getLists.$Params['actor'],
|
||||
actor: did as DidString,
|
||||
limit: PAGE_SIZE,
|
||||
cursor: pageParam,
|
||||
})
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {useCallback, useMemo} from 'react'
|
||||
import {type AppBskyActorDefs} from '@atproto/api'
|
||||
import {type DidString} from '@atproto/syntax'
|
||||
import {
|
||||
type InfiniteData,
|
||||
type QueryClient,
|
||||
@@ -37,8 +38,7 @@ export function useSuggestedFollowsByActorQuery({
|
||||
const data = await client.call(
|
||||
app.bsky.graph.getSuggestedFollowsByActor,
|
||||
{
|
||||
actor:
|
||||
did as app.bsky.graph.getSuggestedFollowsByActor.$Params['actor'],
|
||||
actor: did as DidString,
|
||||
},
|
||||
)
|
||||
const suggestions = data.suggestions.filter(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import {useCallback} from 'react'
|
||||
import {type DidString} from '@atproto/syntax'
|
||||
import {useQueryClient} from '@tanstack/react-query'
|
||||
|
||||
import {logger} from '#/logger'
|
||||
@@ -20,8 +21,7 @@ export function useUpdateProfileVerificationCache() {
|
||||
async ({profile}: {profile: bsky.profile.AnyProfileView}) => {
|
||||
try {
|
||||
const updated = await client.call(app.bsky.actor.getProfile, {
|
||||
actor: (profile.did ??
|
||||
'') as app.bsky.actor.getProfile.$Params['actor'],
|
||||
actor: (profile.did ?? '') as DidString,
|
||||
})
|
||||
updateProfileShadow(qc, profile.did, {
|
||||
verification: updated.verification,
|
||||
|
||||
Reference in New Issue
Block a user