diff --git a/src/components/ageAssurance/AgeAssuranceAppealDialog.tsx b/src/components/ageAssurance/AgeAssuranceAppealDialog.tsx index e3a9dd41a7..722c0594e5 100644 --- a/src/components/ageAssurance/AgeAssuranceAppealDialog.tsx +++ b/src/components/ageAssurance/AgeAssuranceAppealDialog.tsx @@ -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, }, diff --git a/src/components/dialogs/lists/CreateListFromStarterPackDialog.tsx b/src/components/dialogs/lists/CreateListFromStarterPackDialog.tsx index b9979554cd..0a528adedb 100644 --- a/src/components/dialogs/lists/CreateListFromStarterPackDialog.tsx +++ b/src/components/dialogs/lists/CreateListFromStarterPackDialog.tsx @@ -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, }) } diff --git a/src/env/common.ts b/src/env/common.ts index bcda2e4982..0490859898 100644 --- a/src/env/common.ts +++ b/src/env/common.ts @@ -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 diff --git a/src/features/liveNow/index.tsx b/src/features/liveNow/index.tsx index 88daad4df7..de786ba4eb 100644 --- a/src/features/liveNow/index.tsx +++ b/src/features/liveNow/index.tsx @@ -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', }) }, diff --git a/src/screens/Messages/components/ChatDisabled.tsx b/src/screens/Messages/components/ChatDisabled.tsx index 31bdebc4d2..85e89d9315 100644 --- a/src/screens/Messages/components/ChatDisabled.tsx +++ b/src/screens/Messages/components/ChatDisabled.tsx @@ -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, }, diff --git a/src/screens/Settings/components/DeleteAccountDialog.tsx b/src/screens/Settings/components/DeleteAccountDialog.tsx index 0df008280b..892b4ce6b5 100644 --- a/src/screens/Settings/components/DeleteAccountDialog.tsx +++ b/src/screens/Settings/components/DeleteAccountDialog.tsx @@ -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, }) diff --git a/src/screens/Settings/components/ExportCarDialog.tsx b/src/screens/Settings/components/ExportCarDialog.tsx index 6f28aa340f..290f380157 100644 --- a/src/screens/Settings/components/ExportCarDialog.tsx +++ b/src/screens/Settings/components/ExportCarDialog.tsx @@ -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 diff --git a/src/screens/Takendown.tsx b/src/screens/Takendown.tsx index 9843e9337d..a48f264545 100644 --- a/src/screens/Takendown.tsx +++ b/src/screens/Takendown.tsx @@ -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, }, diff --git a/src/state/preferences/moderation-opts.tsx b/src/state/preferences/moderation-opts.tsx index 77ef89f283..a2575c9a50 100644 --- a/src/state/preferences/moderation-opts.tsx +++ b/src/state/preferences/moderation-opts.tsx @@ -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'], }, diff --git a/src/state/queries/activity-subscriptions.ts b/src/state/queries/activity-subscriptions.ts index 31f542bda8..e2753a43c1 100644 --- a/src/state/queries/activity-subscriptions.ts +++ b/src/state/queries/activity-subscriptions.ts @@ -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', }, ) diff --git a/src/state/queries/list-memberships.ts b/src/state/queries/list-memberships.ts index 2bc62f3712..4d4c35e56c 100644 --- a/src/state/queries/list-memberships.ts +++ b/src/state/queries/list-memberships.ts @@ -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, }) }, diff --git a/src/state/queries/list.ts b/src/state/queries/list.ts index 4a9499117c..959dfbb58c 100644 --- a/src/state/queries/list.ts +++ b/src/state/queries/list.ts @@ -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, }) } diff --git a/src/state/queries/messages/actor-declaration.ts b/src/state/queries/messages/actor-declaration.ts index 7f0f363c82..edaea20d0e 100644 --- a/src/state/queries/messages/actor-declaration.ts +++ b/src/state/queries/messages/actor-declaration.ts @@ -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', }) diff --git a/src/state/queries/my-lists.ts b/src/state/queries/my-lists.ts index d529b1e2ad..1150fa74ec 100644 --- a/src/state/queries/my-lists.ts +++ b/src/state/queries/my-lists.ts @@ -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, }) diff --git a/src/state/queries/pinned-post.ts b/src/state/queries/pinned-post.ts index e53cefcbfe..8e36207e40 100644 --- a/src/state/queries/pinned-post.ts +++ b/src/state/queries/pinned-post.ts @@ -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) { diff --git a/src/state/queries/profile-followers.ts b/src/state/queries/profile-followers.ts index 5e79b5719c..59f3c4e842 100644 --- a/src/state/queries/profile-followers.ts +++ b/src/state/queries/profile-followers.ts @@ -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} : {}), diff --git a/src/state/queries/profile-follows.ts b/src/state/queries/profile-follows.ts index 340184ef2c..0f684054b9 100644 --- a/src/state/queries/profile-follows.ts +++ b/src/state/queries/profile-follows.ts @@ -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} : {}), diff --git a/src/state/queries/profile.ts b/src/state/queries/profile.ts index faf4dbc3fe..d0a4379aef 100644 --- a/src/state/queries/profile.ts +++ b/src/state/queries/profile.ts @@ -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, }) }, diff --git a/src/state/session/__tests__/provider-session-events-test.tsx b/src/state/session/__tests__/provider-session-events-test.tsx index e6a51a5414..cd7873b1ba 100644 --- a/src/state/session/__tests__/provider-session-events-test.tsx +++ b/src/state/session/__tests__/provider-session-events-test.tsx @@ -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, }, diff --git a/src/state/session/session-data.ts b/src/state/session/session-data.ts index 3ead91c173..711f6ffe9b 100644 --- a/src/state/session/session-data.ts +++ b/src/state/session/session-data.ts @@ -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, diff --git a/src/view/com/auth/LoggedOut.tsx b/src/view/com/auth/LoggedOut.tsx index 5becdd45d3..b9d0f722c8 100644 --- a/src/view/com/auth/LoggedOut.tsx +++ b/src/view/com/auth/LoggedOut.tsx @@ -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), diff --git a/src/view/com/notifications/NotificationFeedItem.tsx b/src/view/com/notifications/NotificationFeedItem.tsx index e60640c9d6..0087396bb8 100644 --- a/src/view/com/notifications/NotificationFeedItem.tsx +++ b/src/view/com/notifications/NotificationFeedItem.tsx @@ -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, diff --git a/src/view/screens/DebugMod.tsx b/src/view/screens/DebugMod.tsx index c58edac3c9..359d61ef85 100644 --- a/src/view/screens/DebugMod.tsx +++ b/src/view/screens/DebugMod.tsx @@ -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 =