drop the did assertions the brand makes redundant
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import {useState} from 'react'
|
||||
import {View} from 'react-native'
|
||||
import {type DidString} from '@atproto/syntax'
|
||||
import {msg} from '@lingui/core/macro'
|
||||
import {useLingui} from '@lingui/react'
|
||||
import {Trans} from '@lingui/react/macro'
|
||||
@@ -63,7 +62,7 @@ function Inner({control}: {control: Dialog.DialogControlProps}) {
|
||||
subject: {
|
||||
$type: 'com.atproto.admin.defs#repoRef',
|
||||
// the persisted account did is already resolved
|
||||
did: currentAccount.did as DidString,
|
||||
did: currentAccount.did,
|
||||
},
|
||||
reason: `AGE_ASSURANCE_INQUIRY: ` + details,
|
||||
},
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
import {View} from 'react-native'
|
||||
import {TID} from '@atproto/common-web'
|
||||
import {type $Typed} from '@atproto/lex'
|
||||
import {
|
||||
type AtIdentifierString,
|
||||
AtUri,
|
||||
type AtUriString,
|
||||
toDatetimeString,
|
||||
} from '@atproto/syntax'
|
||||
import {AtUri, type AtUriString, toDatetimeString} from '@atproto/syntax'
|
||||
import {msg} from '@lingui/core/macro'
|
||||
import {useLingui} from '@lingui/react'
|
||||
import {Trans} from '@lingui/react/macro'
|
||||
@@ -99,7 +94,7 @@ export function CreateListFromStarterPackDialog({
|
||||
const chunks = chunk(listitemWrites, 50)
|
||||
for (const c of chunks) {
|
||||
await pdsClient.call(com.atproto.repo.applyWrites, {
|
||||
repo: currentAccount.did as AtIdentifierString,
|
||||
repo: currentAccount.did,
|
||||
writes: c,
|
||||
})
|
||||
}
|
||||
|
||||
Vendored
+2
-4
@@ -76,15 +76,13 @@ export const LOG_DEBUG: string = process.env.EXPO_PUBLIC_LOG_DEBUG || ''
|
||||
* The DID of the Bluesky appview to proxy to
|
||||
*/
|
||||
export const BLUESKY_PROXY_DID: DidString =
|
||||
(process.env.EXPO_PUBLIC_BLUESKY_PROXY_DID as DidString) ||
|
||||
'did:web:api.bsky.app'
|
||||
process.env.EXPO_PUBLIC_BLUESKY_PROXY_DID || 'did:web:api.bsky.app'
|
||||
|
||||
/**
|
||||
* The DID of the chat service to proxy to
|
||||
*/
|
||||
export const CHAT_PROXY_DID: DidString =
|
||||
(process.env.EXPO_PUBLIC_CHAT_PROXY_DID as DidString) ||
|
||||
'did:web:api.bsky.chat'
|
||||
process.env.EXPO_PUBLIC_CHAT_PROXY_DID || 'did:web:api.bsky.chat'
|
||||
|
||||
/**
|
||||
* Metrics API host
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {useMemo} from 'react'
|
||||
import {retry} from '@atproto/common-web'
|
||||
import {type $Typed, type l, type UriString} from '@atproto/lex'
|
||||
import {type AtIdentifierString, AtUri, toDatetimeString} from '@atproto/syntax'
|
||||
import {AtUri, toDatetimeString} from '@atproto/syntax'
|
||||
import {moderateStatus} from '@bsky.app/sdk/moderation'
|
||||
import {msg} from '@lingui/core/macro'
|
||||
import {useLingui} from '@lingui/react'
|
||||
@@ -277,7 +277,7 @@ export function useUpsertLiveStatusMutation(
|
||||
|
||||
const upsert = async () => {
|
||||
// the session account is still legacy-typed, so its did is unbranded
|
||||
const repo = currentAccount.did as AtIdentifierString
|
||||
const repo = currentAccount.did
|
||||
const collection = 'app.bsky.actor.status'
|
||||
|
||||
const existing = await pdsClient
|
||||
@@ -369,7 +369,7 @@ export function useRemoveLiveStatusMutation() {
|
||||
if (!currentAccount) throw new Error('Not logged in')
|
||||
|
||||
await pdsClient.delete(app.bsky.actor.status, {
|
||||
repo: currentAccount.did as AtIdentifierString,
|
||||
repo: currentAccount.did,
|
||||
rkey: 'self',
|
||||
})
|
||||
},
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import {useCallback, useState} from 'react'
|
||||
import {type StyleProp, View, type ViewStyle} from 'react-native'
|
||||
import {type DidString} from '@atproto/syntax'
|
||||
import {Trans, useLingui} from '@lingui/react/macro'
|
||||
import {useMutation} from '@tanstack/react-query'
|
||||
|
||||
@@ -107,7 +106,7 @@ function DialogInner() {
|
||||
subject: {
|
||||
$type: 'com.atproto.admin.defs#repoRef',
|
||||
// the persisted account did is already resolved
|
||||
did: currentAccount.did as DidString,
|
||||
did: currentAccount.did,
|
||||
},
|
||||
reason: details,
|
||||
},
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import {useCallback, useRef, useState} from 'react'
|
||||
import {type TextInput, View} from 'react-native'
|
||||
import {type DidString} from '@atproto/syntax'
|
||||
import {msg} from '@lingui/core/macro'
|
||||
import {useLingui} from '@lingui/react'
|
||||
import {Trans} from '@lingui/react/macro'
|
||||
@@ -127,7 +126,7 @@ function DeleteAccountDialogInner({
|
||||
await chatClient.call(chat.bsky.actor.deleteAccount)
|
||||
await client.call(com.atproto.server.deleteAccount, {
|
||||
// the persisted account did is already resolved
|
||||
did: currentAccount.did as DidString,
|
||||
did: currentAccount.did,
|
||||
password,
|
||||
token,
|
||||
})
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import {useCallback, useState} from 'react'
|
||||
import {View} from 'react-native'
|
||||
import {type DidString} from '@atproto/syntax'
|
||||
import {Trans, useLingui} from '@lingui/react/macro'
|
||||
|
||||
import {saveBytesToDisk} from '#/lib/media/manip'
|
||||
@@ -34,7 +33,7 @@ export function ExportCarDialog({
|
||||
}
|
||||
try {
|
||||
setLoading('repo')
|
||||
const did = currentAccount.did as DidString
|
||||
const did = currentAccount.did
|
||||
const data = await pdsClient.call(com.atproto.sync.getRepo, {did})
|
||||
/*
|
||||
* getRepo declares `application/vnd.ipld.car`, so lex-client hands back
|
||||
|
||||
@@ -2,7 +2,6 @@ import {useState} from 'react'
|
||||
import {View} from 'react-native'
|
||||
import {KeyboardAwareScrollView} from 'react-native-keyboard-controller'
|
||||
import {useSafeAreaInsets} from 'react-native-safe-area-context'
|
||||
import {type DidString} from '@atproto/syntax'
|
||||
import {msg} from '@lingui/core/macro'
|
||||
import {useLingui} from '@lingui/react'
|
||||
import {Trans} from '@lingui/react/macro'
|
||||
@@ -58,7 +57,7 @@ export function Takendown() {
|
||||
subject: {
|
||||
$type: 'com.atproto.admin.defs#repoRef',
|
||||
// the persisted account did is already resolved
|
||||
did: currentAccount.did as DidString,
|
||||
did: currentAccount.did,
|
||||
},
|
||||
reason: appealText,
|
||||
},
|
||||
|
||||
@@ -39,11 +39,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||
return undefined
|
||||
}
|
||||
return {
|
||||
/*
|
||||
* `did`/`hiddenPosts` come from persisted storage typed as plain
|
||||
* `string`, so brand them to the SDK's `DidString`/`AtUriString` slots.
|
||||
*/
|
||||
userDid: userDid as ModerationOpts['userDid'],
|
||||
userDid,
|
||||
prefs: {
|
||||
...moderationPrefs,
|
||||
labelers: moderationPrefs.labelers.length
|
||||
@@ -52,6 +48,10 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||
did,
|
||||
labels: DEFAULT_LOGGED_OUT_LABEL_PREFERENCES,
|
||||
})),
|
||||
/*
|
||||
* `hiddenPosts` comes from persisted storage typed as plain `string`,
|
||||
* so brand it to the SDK's `AtUriString` slot.
|
||||
*/
|
||||
hiddenPosts: (hiddenPosts ||
|
||||
[]) as ModerationOpts['prefs']['hiddenPosts'],
|
||||
},
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import {type AtIdentifierString} from '@atproto/syntax'
|
||||
import {t} from '@lingui/core/macro'
|
||||
import {
|
||||
type InfiniteData,
|
||||
@@ -42,7 +41,7 @@ export function useNotificationDeclarationQuery() {
|
||||
try {
|
||||
const response = await client.get(app.bsky.notification.declaration, {
|
||||
// the session account is still legacy-typed, so its did is unbranded
|
||||
repo: currentAccount!.did as AtIdentifierString,
|
||||
repo: currentAccount!.did,
|
||||
rkey: 'self',
|
||||
})
|
||||
return response
|
||||
@@ -72,7 +71,7 @@ export function useNotificationDeclarationMutation() {
|
||||
app.bsky.notification.declaration,
|
||||
record,
|
||||
{
|
||||
repo: currentAccount!.did as AtIdentifierString,
|
||||
repo: currentAccount!.did,
|
||||
rkey: 'self',
|
||||
},
|
||||
)
|
||||
|
||||
@@ -145,7 +145,7 @@ export function useListMembershipRemoveMutation({
|
||||
}
|
||||
const membershipUrip = new AtUri(membershipUri)
|
||||
await pdsClient.delete(app.bsky.graph.listitem, {
|
||||
repo: currentAccount.did as DidString,
|
||||
repo: currentAccount.did,
|
||||
rkey: membershipUrip.rkeySafe,
|
||||
})
|
||||
},
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
import {type $Typed, type Client} from '@atproto/lex'
|
||||
import {
|
||||
type AtIdentifierString,
|
||||
AtUri,
|
||||
type AtUriString,
|
||||
toDatetimeString,
|
||||
} from '@atproto/syntax'
|
||||
import {AtUri, type AtUriString, toDatetimeString} from '@atproto/syntax'
|
||||
import {
|
||||
blockActorList,
|
||||
muteActorList,
|
||||
@@ -195,7 +190,7 @@ export function useListDeleteMutation() {
|
||||
for (let i = 0; i < 100; i++) {
|
||||
const res = await pdsClient.list(app.bsky.graph.listitem, {
|
||||
// the session account is still legacy-typed, so its did is unbranded
|
||||
repo: currentAccount.did as AtIdentifierString,
|
||||
repo: currentAccount.did,
|
||||
cursor,
|
||||
limit: 100,
|
||||
})
|
||||
@@ -228,7 +223,7 @@ export function useListDeleteMutation() {
|
||||
// apply in chunks
|
||||
for (const writesChunk of chunk(writes, 10)) {
|
||||
await pdsClient.call(com.atproto.repo.applyWrites, {
|
||||
repo: currentAccount.did as AtIdentifierString,
|
||||
repo: currentAccount.did,
|
||||
writes: writesChunk,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ export function useUpdateActorDeclaration({
|
||||
})
|
||||
const result = await pdsClient.call(com.atproto.repo.putRecord, {
|
||||
// the session account is still legacy-typed, so its did is unbranded
|
||||
repo: currentAccount.did as DidString,
|
||||
repo: currentAccount.did,
|
||||
collection: 'chat.bsky.actor.declaration',
|
||||
rkey: 'self',
|
||||
record: {
|
||||
@@ -106,7 +106,7 @@ export function useDeleteActorDeclaration() {
|
||||
mutationFn: async () => {
|
||||
if (!currentAccount) throw new Error('Not signed in')
|
||||
const result = await pdsClient.call(com.atproto.repo.deleteRecord, {
|
||||
repo: currentAccount.did as DidString,
|
||||
repo: currentAccount.did,
|
||||
collection: 'chat.bsky.actor.declaration',
|
||||
rkey: 'self',
|
||||
})
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import {type DidString} from '@atproto/syntax'
|
||||
import {type QueryClient, useQuery} from '@tanstack/react-query'
|
||||
|
||||
import {accumulate} from '#/lib/async/accumulate'
|
||||
@@ -27,7 +26,7 @@ export function useMyListsQuery(filter: MyListsFilter) {
|
||||
accumulate(cursor =>
|
||||
client
|
||||
.call(app.bsky.graph.getLists, {
|
||||
actor: currentAccount!.did as DidString,
|
||||
actor: currentAccount!.did,
|
||||
cursor,
|
||||
limit: 50,
|
||||
})
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import {type DidString} from '@atproto/syntax'
|
||||
import {msg} from '@lingui/core/macro'
|
||||
import {useLingui} from '@lingui/react'
|
||||
import {useMutation, useQueryClient} from '@tanstack/react-query'
|
||||
@@ -36,7 +35,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 DidString,
|
||||
actor: currentAccount.did,
|
||||
})
|
||||
prevPinnedPost = profile.pinnedPost?.uri
|
||||
if (prevPinnedPost && prevPinnedPost !== postUri) {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import {type DidString} from '@atproto/syntax'
|
||||
import {
|
||||
type InfiniteData,
|
||||
type QueryClient,
|
||||
@@ -51,7 +50,7 @@ export function useProfileFollowersQuery(
|
||||
* is `undefined`, hence the conditional spread.
|
||||
*/
|
||||
return await client.call(app.bsky.graph.getFollowers, {
|
||||
actor: (did || '') as DidString,
|
||||
actor: did || '',
|
||||
limit: PAGE_SIZE,
|
||||
cursor: pageParam,
|
||||
...(sortParam ? {sort: sortParam} : {}),
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import {type DidString} from '@atproto/syntax'
|
||||
import {
|
||||
type InfiniteData,
|
||||
type QueryClient,
|
||||
@@ -56,7 +55,7 @@ export function useProfileFollowsQuery(
|
||||
* is `undefined`, hence the conditional spread.
|
||||
*/
|
||||
return await client.call(app.bsky.graph.getFollows, {
|
||||
actor: (did || '') as DidString,
|
||||
actor: did || '',
|
||||
limit: limit || PAGE_SIZE,
|
||||
cursor: pageParam,
|
||||
...(sortParam ? {sort: sortParam} : {}),
|
||||
|
||||
@@ -666,7 +666,7 @@ function useProfileUnblockMutation() {
|
||||
}
|
||||
const {rkeySafe: rkey} = new AtUri(blockUri)
|
||||
await pdsClient.delete(app.bsky.graph.block, {
|
||||
repo: currentAccount.did as AtIdentifierString,
|
||||
repo: currentAccount.did,
|
||||
rkey,
|
||||
})
|
||||
},
|
||||
|
||||
@@ -173,7 +173,7 @@ function makeBundle(account: SessionAccount): FakeBundle {
|
||||
refreshJwt: account.refreshJwt ?? '',
|
||||
/* SessionData types these as branded strings; the values are fixtures */
|
||||
handle: account.handle as `${string}.${string}`,
|
||||
did: account.did as `did:${string}:${string}`,
|
||||
did: account.did,
|
||||
active: true,
|
||||
service: account.service,
|
||||
},
|
||||
|
||||
@@ -69,7 +69,7 @@ export function sessionAccountToSessionData(
|
||||
return {
|
||||
accessJwt: account.accessJwt ?? '',
|
||||
active: account.active ?? true,
|
||||
did: account.did as SessionData['did'],
|
||||
did: account.did,
|
||||
email: account.email,
|
||||
emailAuthFactor: account.emailAuthFactor,
|
||||
emailConfirmed: account.emailConfirmed,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import {useCallback, useEffect, useState} from 'react'
|
||||
import {View} from 'react-native'
|
||||
import {useSafeAreaInsets} from 'react-native-safe-area-context'
|
||||
import {type DidString} from '@atproto/syntax'
|
||||
import {useLingui} from '@lingui/react/macro'
|
||||
import {useQueryClient} from '@tanstack/react-query'
|
||||
|
||||
@@ -69,7 +68,7 @@ export function LoggedOut({onDismiss}: {onDismiss?: () => void}) {
|
||||
const {accounts} = useSession()
|
||||
const client = useAppviewClient()
|
||||
useEffect(() => {
|
||||
const actors = accounts.map(acc => acc.did as DidString)
|
||||
const actors = accounts.map(acc => acc.did)
|
||||
if (actors.length === 0) return
|
||||
void queryClient.prefetchQuery({
|
||||
queryKey: profilesQueryKey(actors),
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
View,
|
||||
} from 'react-native'
|
||||
import {TID} from '@atproto/common-web'
|
||||
import {AtUri, type DidString} from '@atproto/syntax'
|
||||
import {AtUri} from '@atproto/syntax'
|
||||
import {
|
||||
moderateProfile,
|
||||
type ModerationDecision,
|
||||
@@ -915,7 +915,7 @@ function SayHelloBtn({profile}: {profile: app.bsky.actor.defs.ProfileView}) {
|
||||
const data = await client.call(chat.bsky.convo.getConvoForMembers, {
|
||||
// both dids are already resolved - one from the profile view, one from
|
||||
// the active session
|
||||
members: [profile.did, currentAccount!.did] as DidString[],
|
||||
members: [profile.did, currentAccount!.did],
|
||||
})
|
||||
navigation.navigate('MessagesConversation', {
|
||||
conversation: data.convo.id,
|
||||
|
||||
@@ -341,7 +341,7 @@ export const DebugModScreen = ({}: NativeStackScreenProps<
|
||||
blockingByList: undefined,
|
||||
}),
|
||||
})
|
||||
mockedProfile.did = did as app.bsky.actor.defs.ProfileViewBasic['did']
|
||||
mockedProfile.did = did
|
||||
mockedProfile.avatar = 'https://bsky.social/about/images/favicon-32x32.png'
|
||||
// @ts-expect-error ProfileViewBasic is close enough -esb
|
||||
mockedProfile.banner =
|
||||
|
||||
Reference in New Issue
Block a user