diff --git a/src/components/PostControls/PostMenu/PostMenuItems.tsx b/src/components/PostControls/PostMenu/PostMenuItems.tsx index 1d54687a2..5a0184141 100644 --- a/src/components/PostControls/PostMenu/PostMenuItems.tsx +++ b/src/components/PostControls/PostMenu/PostMenuItems.tsx @@ -17,7 +17,6 @@ import { type AppBskyFeedThreadgate, AtUri, type BlobRef, - isDid, type RichText as RichTextAPI, } from '@atproto/api' import {msg} from '@lingui/macro' @@ -44,8 +43,11 @@ import {logger} from '#/logger' import {type Shadow} from '#/state/cache/post-shadow' import {useProfileShadow} from '#/state/cache/profile-shadow' import {useFeedFeedbackContext} from '#/state/feed-feedback' -import {useLanguagePrefs} from '#/state/preferences' -import {useHiddenPosts, useHiddenPostsApi} from '#/state/preferences' +import { + useHiddenPosts, + useHiddenPostsApi, + useLanguagePrefs, +} from '#/state/preferences' import {usePinnedPostMutation} from '#/state/queries/pinned-post' import { usePostDeleteMutation, @@ -58,11 +60,11 @@ import { useProfileMuteMutationQueue, } from '#/state/queries/profile' import {resolvePdsServiceUrl} from '#/state/queries/resolve-identity' -import {useToggleReplyVisibilityMutation} from '#/state/queries/threadgate' import { InvalidInteractionSettingsError, MAX_HIDDEN_REPLIES, MaxHiddenRepliesError, + useToggleReplyVisibilityMutation, } from '#/state/queries/threadgate' import {useRequireAuth, useSession} from '#/state/session' import {useMergedThreadgateHiddenReplies} from '#/state/threadgate-hidden-replies' @@ -84,14 +86,18 @@ import { import {Eye_Stroke2_Corner0_Rounded as Eye} from '#/components/icons/Eye' import {EyeSlash_Stroke2_Corner0_Rounded as EyeSlash} from '#/components/icons/EyeSlash' import {Filter_Stroke2_Corner0_Rounded as Filter} from '#/components/icons/Filter' -import {Mute_Stroke2_Corner0_Rounded as MuteIcon} from '#/components/icons/Mute' -import {Mute_Stroke2_Corner0_Rounded as Mute} from '#/components/icons/Mute' +import { + Mute_Stroke2_Corner0_Rounded as Mute, + Mute_Stroke2_Corner0_Rounded as MuteIcon, +} from '#/components/icons/Mute' import {Pencil_Stroke2_Corner0_Rounded as Pen} from '#/components/icons/Pencil' import {PersonX_Stroke2_Corner0_Rounded as PersonX} from '#/components/icons/Person' import {Pin_Stroke2_Corner0_Rounded as PinIcon} from '#/components/icons/Pin' import {SettingsGear2_Stroke2_Corner0_Rounded as Gear} from '#/components/icons/SettingsGear2' -import {SpeakerVolumeFull_Stroke2_Corner0_Rounded as UnmuteIcon} from '#/components/icons/Speaker' -import {SpeakerVolumeFull_Stroke2_Corner0_Rounded as Unmute} from '#/components/icons/Speaker' +import { + SpeakerVolumeFull_Stroke2_Corner0_Rounded as Unmute, + SpeakerVolumeFull_Stroke2_Corner0_Rounded as UnmuteIcon, +} from '#/components/icons/Speaker' import {Trash_Stroke2_Corner0_Rounded as Trash} from '#/components/icons/Trash' import {Warning_Stroke2_Corner0_Rounded as Warning} from '#/components/icons/Warning' import {Loader} from '#/components/Loader' @@ -603,8 +609,8 @@ let PostMenuItems = ({ if (!videoEmbed) return const did = post.author.did const cid = videoEmbed.cid - if (!isDid(did)) return - const pdsUrl = await resolvePdsServiceUrl(did as `did:${string}:${string}`) + if (!did.startsWith('did:')) return + const pdsUrl = await resolvePdsServiceUrl(did as `did:${string}`) const uri = `${pdsUrl}/xrpc/com.atproto.sync.getBlob?did=${did}&cid=${cid}` Toast.show(_(msg({message: 'Downloading video...', context: 'toast'}))) diff --git a/src/components/dialogs/EmailDialog/data/useConfirmEmail.ts b/src/components/dialogs/EmailDialog/data/useConfirmEmail.ts index ce68a9b8a..67466be92 100644 --- a/src/components/dialogs/EmailDialog/data/useConfirmEmail.ts +++ b/src/components/dialogs/EmailDialog/data/useConfirmEmail.ts @@ -1,7 +1,6 @@ import {useMutation} from '@tanstack/react-query' import {useAgent, useSession} from '#/state/session' -import {pdsAgent} from '#/state/session/agent' export function useConfirmEmail({ onSuccess, @@ -16,7 +15,7 @@ export function useConfirmEmail({ throw new Error('No email found for the current account') } - await pdsAgent(agent).com.atproto.server.confirmEmail({ + await agent.com.atproto.server.confirmEmail({ email: currentAccount.email.trim(), token: token.trim(), }) diff --git a/src/components/dialogs/EmailDialog/data/useManageEmail2FA.ts b/src/components/dialogs/EmailDialog/data/useManageEmail2FA.ts index b862d3a30..358bf8654 100644 --- a/src/components/dialogs/EmailDialog/data/useManageEmail2FA.ts +++ b/src/components/dialogs/EmailDialog/data/useManageEmail2FA.ts @@ -1,7 +1,6 @@ import {useMutation} from '@tanstack/react-query' import {useAgent, useSession} from '#/state/session' -import {pdsAgent} from '#/state/session/agent' export function useManageEmail2FA() { const agent = useAgent() @@ -18,7 +17,7 @@ export function useManageEmail2FA() { throw new Error('No email found for the current account') } - await pdsAgent(agent).com.atproto.server.updateEmail({ + await agent.com.atproto.server.updateEmail({ email: currentAccount.email, emailAuthFactor: enabled, token, diff --git a/src/components/dialogs/EmailDialog/data/useRequestEmailUpdate.ts b/src/components/dialogs/EmailDialog/data/useRequestEmailUpdate.ts index 99816e663..a442662fc 100644 --- a/src/components/dialogs/EmailDialog/data/useRequestEmailUpdate.ts +++ b/src/components/dialogs/EmailDialog/data/useRequestEmailUpdate.ts @@ -1,15 +1,13 @@ import {useMutation} from '@tanstack/react-query' import {useAgent} from '#/state/session' -import {pdsAgent} from '#/state/session/agent' export function useRequestEmailUpdate() { const agent = useAgent() return useMutation({ mutationFn: async () => { - return (await pdsAgent(agent).com.atproto.server.requestEmailUpdate()) - .data + return (await agent.com.atproto.server.requestEmailUpdate()).data }, }) } diff --git a/src/components/dialogs/EmailDialog/data/useRequestEmailVerification.ts b/src/components/dialogs/EmailDialog/data/useRequestEmailVerification.ts index 34cd5270f..ae308c7af 100644 --- a/src/components/dialogs/EmailDialog/data/useRequestEmailVerification.ts +++ b/src/components/dialogs/EmailDialog/data/useRequestEmailVerification.ts @@ -1,14 +1,13 @@ import {useMutation} from '@tanstack/react-query' import {useAgent} from '#/state/session' -import {pdsAgent} from '#/state/session/agent' export function useRequestEmailVerification() { const agent = useAgent() return useMutation({ mutationFn: async () => { - await pdsAgent(agent).com.atproto.server.requestEmailConfirmation() + await agent.com.atproto.server.requestEmailConfirmation() }, }) } diff --git a/src/components/dialogs/EmailDialog/data/useUpdateEmail.ts b/src/components/dialogs/EmailDialog/data/useUpdateEmail.ts index 644461f9f..2ec1eb6dc 100644 --- a/src/components/dialogs/EmailDialog/data/useUpdateEmail.ts +++ b/src/components/dialogs/EmailDialog/data/useUpdateEmail.ts @@ -1,7 +1,6 @@ import {useMutation} from '@tanstack/react-query' import {useAgent} from '#/state/session' -import {pdsAgent} from '#/state/session/agent' import {useRequestEmailUpdate} from '#/components/dialogs/EmailDialog/data/useRequestEmailUpdate' async function updateEmailAndRefreshSession( @@ -9,10 +8,7 @@ async function updateEmailAndRefreshSession( email: string, token?: string, ) { - await pdsAgent(agent).com.atproto.server.updateEmail({ - email: email.trim(), - token, - }) + await agent.com.atproto.server.updateEmail({email: email.trim(), token}) await agent.resumeSession(agent.session!) } diff --git a/src/components/intents/VerifyEmailIntentDialog.tsx b/src/components/intents/VerifyEmailIntentDialog.tsx index 00588e89f..26ba2d5b6 100644 --- a/src/components/intents/VerifyEmailIntentDialog.tsx +++ b/src/components/intents/VerifyEmailIntentDialog.tsx @@ -4,7 +4,6 @@ import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import {useAgent, useSession} from '#/state/session' -import {pdsAgent} from '#/state/session/agent' import {atoms as a, useBreakpoints, useTheme} from '#/alf' import {Button, ButtonIcon, ButtonText} from '#/components/Button' import * as Dialog from '#/components/Dialog' @@ -52,7 +51,7 @@ function Inner({}: {control: DialogControlProps}) { const onPressResendEmail = async () => { setSending(true) - await pdsAgent(agent).com.atproto.server.requestEmailConfirmation() + await agent.com.atproto.server.requestEmailConfirmation() setSending(false) setStatus('resent') } diff --git a/src/components/live/queries.ts b/src/components/live/queries.ts index ec2c99d3b..7db944d06 100644 --- a/src/components/live/queries.ts +++ b/src/components/live/queries.ts @@ -16,7 +16,6 @@ import {logger} from '#/logger' import {updateProfileShadow} from '#/state/cache/profile-shadow' import {useLiveNowConfig} from '#/state/service-config' import {useAgent, useSession} from '#/state/session' -import {pdsAgent} from '#/state/session/agent' import * as Toast from '#/view/com/util/Toast' import {useDialogContext} from '#/components/Dialog' import {getLiveServiceNames} from '#/components/live/utils' @@ -110,11 +109,11 @@ export function useUpsertLiveStatusMutation( const repo = currentAccount.did const collection = 'app.bsky.actor.status' - const existing = await pdsAgent(agent) - .com.atproto.repo.getRecord({repo, collection, rkey: 'self'}) + const existing = await agent.com.atproto.repo + .getRecord({repo, collection, rkey: 'self'}) .catch(_e => undefined) - await pdsAgent(agent).com.atproto.repo.putRecord({ + await agent.com.atproto.repo.putRecord({ repo, collection, rkey: 'self', diff --git a/src/env/common.ts b/src/env/common.ts index e5e3f1db0..02c07dfd3 100644 --- a/src/env/common.ts +++ b/src/env/common.ts @@ -118,13 +118,3 @@ export const GEOLOCATION_URL = IS_DEV * URLs for the live-event config web worker. Can be a * locally running server, see `env.example` for more. */ -export const LIVE_EVENTS_DEV_URL = process.env.LIVE_EVENTS_DEV_URL -export const LIVE_EVENTS_PROD_URL = `https://live-events.workers.bsky.app` -export const LIVE_EVENTS_URL = IS_DEV - ? (LIVE_EVENTS_DEV_URL ?? LIVE_EVENTS_PROD_URL) - : LIVE_EVENTS_PROD_URL - -export const ENV_PUBLIC_BSKY_SERVICE: string | undefined = - process.env.EXPO_PUBLIC_PUBLIC_BSKY_SERVICE -export const ENV_APPVIEW_DID_PROXY: `did:${string}:${string}#bsky_appview` | undefined = - process.env.EXPO_PUBLIC_APPVIEW_DID_PROXY \ No newline at end of file diff --git a/src/lib/api/feed/custom.ts b/src/lib/api/feed/custom.ts index d6bea2c79..18bb8c8f0 100644 --- a/src/lib/api/feed/custom.ts +++ b/src/lib/api/feed/custom.ts @@ -5,7 +5,6 @@ import { jsonStringToLex, } from '@atproto/api' -import {PUBLIC_BSKY_SERVICE} from '#/lib/constants' import { getAppLanguageAsContentLanguage, getContentLanguages, @@ -121,7 +120,7 @@ async function loggedOutFetch({ // manually construct fetch call so we can add the `lang` cache-busting param let res = await fetch( - `${PUBLIC_BSKY_SERVICE}/xrpc/app.bsky.feed.getFeed?feed=${feed}${ + `https://api.bsky.app/xrpc/app.bsky.feed.getFeed?feed=${feed}${ cursor ? `&cursor=${cursor}` : '' }&limit=${limit}&lang=${contentLangs}`, { @@ -141,7 +140,7 @@ async function loggedOutFetch({ // no data, try again with language headers removed res = await fetch( - `${PUBLIC_BSKY_SERVICE}/xrpc/app.bsky.feed.getFeed?feed=${feed}${ + `https://api.bsky.app/xrpc/app.bsky.feed.getFeed?feed=${feed}${ cursor ? `&cursor=${cursor}` : '' }&limit=${limit}`, {method: 'GET', headers: {'Accept-Language': '', ...labelersHeader}}, diff --git a/src/lib/api/index.ts b/src/lib/api/index.ts index e8212dacd..128581bad 100644 --- a/src/lib/api/index.ts +++ b/src/lib/api/index.ts @@ -23,7 +23,11 @@ import {CID} from 'multiformats/cid' import * as Hasher from 'multiformats/hashes/hasher' import {isNetworkError} from '#/lib/strings/errors' -import {parseMarkdownLinks,shortenLinks, stripInvalidMentions} from '#/lib/strings/rich-text-manip' +import { + parseMarkdownLinks, + shortenLinks, + stripInvalidMentions, +} from '#/lib/strings/rich-text-manip' import {logger} from '#/logger' import {compressImage} from '#/state/gallery' import { @@ -34,7 +38,6 @@ import { createThreadgateRecord, threadgateAllowUISettingToAllowRecordValue, } from '#/state/queries/threadgate' -import {pdsAgent} from '#/state/session/agent' import { type EmbedDraft, type PostDraft, @@ -173,7 +176,7 @@ export async function post( } try { - await pdsAgent(agent).com.atproto.repo.applyWrites({ + await agent.com.atproto.repo.applyWrites({ repo: agent.assertDid, writes: writes, validate: true, @@ -370,11 +373,15 @@ async function resolveMedia( const width = Math.round( videoDraft.asset?.width || - ('redraftDimensions' in videoDraft ? videoDraft.redraftDimensions.width : 1000) + ('redraftDimensions' in videoDraft + ? videoDraft.redraftDimensions.width + : 1000), ) const height = Math.round( videoDraft.asset?.height || - ('redraftDimensions' in videoDraft ? videoDraft.redraftDimensions.height : 1000) + ('redraftDimensions' in videoDraft + ? videoDraft.redraftDimensions.height + : 1000), ) // aspect ratio values must be >0 - better to leave as unset otherwise diff --git a/src/lib/constants.ts b/src/lib/constants.ts index 7c322afe5..43180004d 100644 --- a/src/lib/constants.ts +++ b/src/lib/constants.ts @@ -3,20 +3,18 @@ import {type AppBskyActorDefs, BSKY_LABELER_DID} from '@atproto/api' import {type ProxyHeaderValue} from '#/state/session/agent' import {BLUESKY_PROXY_DID, CHAT_PROXY_DID} from '#/env' -import {ENV_APPVIEW_DID_PROXY, ENV_PUBLIC_BSKY_SERVICE} from '#/env' + export const LOCAL_DEV_SERVICE = Platform.OS === 'android' ? 'http://10.0.2.2:2583' : 'http://localhost:2583' export const STAGING_SERVICE = 'https://staging.bsky.dev' export const BSKY_SERVICE = 'https://bsky.social' export const BSKY_SERVICE_DID = 'did:web:bsky.social' -export const PUBLIC_BSKY_SERVICE = - ENV_PUBLIC_BSKY_SERVICE || 'https://public.api.bsky.app' +export const PUBLIC_BSKY_SERVICE = 'https://public.api.bsky.app' export const DEFAULT_SERVICE = BSKY_SERVICE export const HELP_DESK_URL = `https://tangled.org/jollywhoppers.com/witchsky.app/` export const EMBED_SERVICE = 'https://embed.bsky.app' export const EMBED_SCRIPT = `${EMBED_SERVICE}/static/embed.js` export const BSKY_DOWNLOAD_URL = 'https://bsky.app/download' -export const APPVIEW_DID_PROXY = ENV_APPVIEW_DID_PROXY export const STARTER_PACK_MAX_SIZE = 150 export const CARD_ASPECT_RATIO = 1200 / 630 diff --git a/src/lib/generate-starterpack.ts b/src/lib/generate-starterpack.ts index 61a5be8ac..76bef3fbe 100644 --- a/src/lib/generate-starterpack.ts +++ b/src/lib/generate-starterpack.ts @@ -15,7 +15,6 @@ import {sanitizeDisplayName} from '#/lib/strings/display-names' import {sanitizeHandle} from '#/lib/strings/handles' import {enforceLen} from '#/lib/strings/helpers' import {useAgent} from '#/state/session' -import {pdsAgent} from '#/state/session/agent' import type * as bsky from '#/types/bsky' export const createStarterPackList = async ({ @@ -45,7 +44,7 @@ export const createStarterPackList = async ({ }, ) if (!list) throw new Error('List creation failed') - await pdsAgent(agent).com.atproto.repo.applyWrites({ + await agent.com.atproto.repo.applyWrites({ repo: agent.session!.did, writes: profiles.map(p => createListItem({did: p.did, listUri: list.uri})), }) diff --git a/src/lib/media/video/upload.shared.ts b/src/lib/media/video/upload.shared.ts index 3c4c4a4de..f74efa03a 100644 --- a/src/lib/media/video/upload.shared.ts +++ b/src/lib/media/video/upload.shared.ts @@ -5,7 +5,6 @@ import {msg} from '@lingui/macro' import {VIDEO_SERVICE_DID} from '#/lib/constants' import {UploadLimitError} from '#/lib/media/video/errors' import {getServiceAuthAudFromUrl} from '#/lib/strings/url-helpers' -import {pdsAgent} from '#/state/session/agent' import {createVideoAgent} from './util' export async function getServiceAuthToken({ @@ -23,9 +22,7 @@ export async function getServiceAuthToken({ if (!pdsAud) { throw new Error('Agent does not have a PDS URL') } - const {data: serviceAuth} = await pdsAgent( - agent, - ).com.atproto.server.getServiceAuth({ + const {data: serviceAuth} = await agent.com.atproto.server.getServiceAuth({ aud: aud ?? pdsAud, lxm, exp, diff --git a/src/lib/react-query.tsx b/src/lib/react-query.tsx index 44e64fd8f..47b3846f6 100644 --- a/src/lib/react-query.tsx +++ b/src/lib/react-query.tsx @@ -11,7 +11,6 @@ import type React from 'react' import {listenNetworkConfirmed, listenNetworkLost} from '#/state/events' import {IS_NATIVE, IS_WEB} from '#/env' -import {PUBLIC_BSKY_SERVICE} from './constants' declare global { interface Window { @@ -29,7 +28,7 @@ async function checkIsOnline(): Promise { setTimeout(() => { controller.abort() }, 15e3) - const res = await fetch(`${PUBLIC_BSKY_SERVICE}/xrpc/_health`, { + const res = await fetch('https://public.api.bsky.app/xrpc/_health', { cache: 'no-store', signal: controller.signal, }) diff --git a/src/screens/Deactivated.tsx b/src/screens/Deactivated.tsx index 2074f1ce5..2e16695fe 100644 --- a/src/screens/Deactivated.tsx +++ b/src/screens/Deactivated.tsx @@ -13,7 +13,6 @@ import { useSession, useSessionApi, } from '#/state/session' -import {pdsAgent} from '#/state/session/agent' import {useLoggedOutViewControls} from '#/state/shell/logged-out' import {Logo} from '#/view/icons/Logo' import {atoms as a, useTheme} from '#/alf' @@ -70,7 +69,7 @@ export function Deactivated() { const handleActivate = React.useCallback(async () => { try { setPending(true) - await pdsAgent(agent).com.atproto.server.activateAccount() + await agent.com.atproto.server.activateAccount() await queryClient.resetQueries() await agent.resumeSession(agent.session!) } catch (e: any) { diff --git a/src/screens/Onboarding/util.ts b/src/screens/Onboarding/util.ts index 98ff3af62..b08f0408e 100644 --- a/src/screens/Onboarding/util.ts +++ b/src/screens/Onboarding/util.ts @@ -9,7 +9,6 @@ import {TID} from '@atproto/common-web' import chunk from 'lodash.chunk' import {until} from '#/lib/async/until' -import {pdsAgent} from '#/state/session/agent' export async function bulkWriteFollows(agent: BskyAgent, dids: string[]) { const session = agent.session @@ -36,7 +35,7 @@ export async function bulkWriteFollows(agent: BskyAgent, dids: string[]) { const chunks = chunk(followWrites, 50) for (const chunk of chunks) { - await pdsAgent(agent).com.atproto.repo.applyWrites({ + await agent.com.atproto.repo.applyWrites({ repo: session.did, writes: chunk, }) diff --git a/src/screens/Settings/DeerSettings.tsx b/src/screens/Settings/DeerSettings.tsx index 9417f39e0..38f43a75c 100644 --- a/src/screens/Settings/DeerSettings.tsx +++ b/src/screens/Settings/DeerSettings.tsx @@ -1,12 +1,10 @@ import {useState} from 'react' import {View} from 'react-native' -import {isDid} from '@atproto/api' import {type ProfileViewBasic} from '@atproto/api/dist/client/types/app/bsky/actor/defs' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import {type NativeStackScreenProps} from '@react-navigation/native-stack' -import {APPVIEW_DID_PROXY} from '#/lib/constants' import {usePalette} from '#/lib/hooks/usePalette' import {type CommonNavigatorParams} from '#/lib/routes/types' import {type Gate} from '#/lib/statsig/gates' @@ -21,7 +19,6 @@ import { useConstellationInstance, useSetConstellationInstance, } from '#/state/preferences/constellation-instance' -import {useCustomAppViewDid} from '#/state/preferences/custom-appview-did' import { useDeerVerificationEnabled, useDeerVerificationTrusted, @@ -113,8 +110,6 @@ import { useShowLinkInHandle, } from '#/state/preferences/show-link-in-handle.tsx' import {useProfilesQuery} from '#/state/queries/profile' -import {findService, useDidDocument} from '#/state/queries/resolve-identity' -import {ErrorMessage} from '#/view/com/util/error/ErrorMessage' import * as SettingsList from '#/screens/Settings/components/SettingsList' import {atoms as a, useBreakpoints} from '#/alf' import {Admonition} from '#/components/Admonition' @@ -133,6 +128,7 @@ import * as Layout from '#/components/Layout' import {Text} from '#/components/Typography' import {IS_WEB} from '#/env' import {SearchProfileCard} from '../Search/components/SearchProfileCard' + type Props = NativeStackScreenProps const defaultGateValues = { @@ -229,136 +225,6 @@ function ConstellationInstanceDialog({ ) } -function CustomAppViewDidDialog({ - control, -}: { - control: Dialog.DialogControlProps -}) { - const pal = usePalette('default') - const {_} = useLingui() - - const [did, setDid] = useState('') - const [, setCustomAppViewDid] = useCustomAppViewDid() - - const doc = useDidDocument({did}) - const bskyAppViewService = - doc.data && findService(doc.data, '#bsky_appview', 'BskyAppView') - - const submit = () => { - if (did.length === 0) { - setCustomAppViewDid(undefined) - control.close() - return - } - if (!bskyAppViewService?.serviceEndpoint) return - setCustomAppViewDid(did) - control.close() - } - - return ( - setDid('')}> - - - - - Custom AppView Proxy DID - - - - - { - setDid(value) - }} - placeholder={ - APPVIEW_DID_PROXY?.substring(0, APPVIEW_DID_PROXY.indexOf('#')) || - `did:web:api.bsky.app` - } - placeholderTextColor={pal.colors.textLight} - onSubmitEditing={submit} - accessibilityHint={_( - msg`Input the DID of the AppView to proxy requests through`, - )} - isInvalid={ - !!did && !bskyAppViewService?.serviceEndpoint && !doc.isLoading - } - /> - - {did && !isDid(did) && ( - - - - )} - - {did && (did.includes('#') || did.includes('?')) && ( - - - - )} - - {doc.isError && ( - - - - )} - - {doc.data && - !bskyAppViewService && - (doc.data as {message?: string}).message && ( - - - - )} - - {doc.data && !bskyAppViewService && ( - - - - )} - - {bskyAppViewService && ( - - {JSON.stringify(bskyAppViewService, null, 2)} - - )} - - - - - - - - - - ) -} - function TrustedVerifiersDialog({ control, }: { @@ -498,8 +364,6 @@ export function DeerSettingsScreen({}: Props) { [gate]: value, }) } - const [customAppViewDid] = useCustomAppViewDid() - const setCustomAppViewDidControl = Dialog.useDialogControl() return ( @@ -644,25 +508,6 @@ export function DeerSettingsScreen({}: Props) { - - - - {`Custom AppView DID`} - - setCustomAppViewDidControl.open()} - /> - - - - - Restart app after changing your AppView. - {customAppViewDid && _(` Currently ${customAppViewDid}`)} - - - - @@ -1003,7 +848,6 @@ export function DeerSettingsScreen({}: Props) { - ) diff --git a/src/screens/Settings/components/ChangePasswordDialog.tsx b/src/screens/Settings/components/ChangePasswordDialog.tsx index 0a32cb95a..1a4f36bee 100644 --- a/src/screens/Settings/components/ChangePasswordDialog.tsx +++ b/src/screens/Settings/components/ChangePasswordDialog.tsx @@ -8,7 +8,6 @@ import {cleanError, isNetworkError} from '#/lib/strings/errors' import {checkAndFormatResetCode} from '#/lib/strings/password' import {logger} from '#/logger' import {useAgent, useSession} from '#/state/session' -import {pdsAgent} from '#/state/session/agent' import {ErrorMessage} from '#/view/com/util/error/ErrorMessage' import {android, atoms as a, web} from '#/alf' import {Button, ButtonIcon, ButtonText} from '#/components/Button' @@ -85,7 +84,7 @@ function Inner() { setError('') setIsProcessing(true) try { - await pdsAgent(agent).com.atproto.server.requestPasswordReset({ + await agent.com.atproto.server.requestPasswordReset({ email: currentAccount.email, }) setStage(Stages.ChangePassword) @@ -129,7 +128,7 @@ function Inner() { setError('') setIsProcessing(true) try { - await pdsAgent(agent).com.atproto.server.resetPassword({ + await agent.com.atproto.server.resetPassword({ token: formattedCode, password: newPassword, }) diff --git a/src/screens/Settings/components/DeactivateAccountDialog.tsx b/src/screens/Settings/components/DeactivateAccountDialog.tsx index c0eb3e33f..4570062ce 100644 --- a/src/screens/Settings/components/DeactivateAccountDialog.tsx +++ b/src/screens/Settings/components/DeactivateAccountDialog.tsx @@ -5,7 +5,6 @@ import {useLingui} from '@lingui/react' import {logger} from '#/logger' import {useAgent, useSessionApi} from '#/state/session' -import {pdsAgent} from '#/state/session/agent' import {atoms as a, useBreakpoints, useTheme} from '#/alf' import {Button, ButtonIcon, ButtonText} from '#/components/Button' import {type DialogOuterProps} from '#/components/Dialog' @@ -43,7 +42,7 @@ function DeactivateAccountDialogInner({ const handleDeactivate = React.useCallback(async () => { try { setPending(true) - await pdsAgent(agent).com.atproto.server.deactivateAccount({}) + await agent.com.atproto.server.deactivateAccount({}) control.close(() => { logoutCurrentAccount('Deactivated') }) diff --git a/src/screens/Settings/components/DisableEmail2FADialog.tsx b/src/screens/Settings/components/DisableEmail2FADialog.tsx index 12a589dcc..2263ee1b3 100644 --- a/src/screens/Settings/components/DisableEmail2FADialog.tsx +++ b/src/screens/Settings/components/DisableEmail2FADialog.tsx @@ -5,7 +5,6 @@ import {useLingui} from '@lingui/react' import {cleanError} from '#/lib/strings/errors' import {useAgent, useSession} from '#/state/session' -import {pdsAgent} from '#/state/session/agent' import {ErrorMessage} from '#/view/com/util/error/ErrorMessage' import * as Toast from '#/view/com/util/Toast' import {atoms as a, useBreakpoints, useTheme} from '#/alf' @@ -42,7 +41,7 @@ export function DisableEmail2FADialog({ setError('') setIsProcessing(true) try { - await pdsAgent(agent).com.atproto.server.requestEmailUpdate() + await agent.com.atproto.server.requestEmailUpdate() setStage(Stages.ConfirmCode) } catch (e) { setError(cleanError(String(e))) @@ -56,8 +55,8 @@ export function DisableEmail2FADialog({ setIsProcessing(true) try { if (currentAccount?.email) { - await pdsAgent(agent).com.atproto.server.updateEmail({ - email: currentAccount!.email, + await agent.com.atproto.server.updateEmail({ + email: currentAccount.email, token: confirmationCode.trim(), emailAuthFactor: false, }) diff --git a/src/screens/Settings/components/ExportCarDialog.tsx b/src/screens/Settings/components/ExportCarDialog.tsx index 364c95d25..cf4756476 100644 --- a/src/screens/Settings/components/ExportCarDialog.tsx +++ b/src/screens/Settings/components/ExportCarDialog.tsx @@ -6,7 +6,6 @@ import {useLingui} from '@lingui/react' import {saveBytesToDisk} from '#/lib/media/manip' import {logger} from '#/logger' import {useAgent} from '#/state/session' -import {pdsAgent} from '#/state/session/agent' import {atoms as a, useTheme, web} from '#/alf' import {Button, ButtonIcon, ButtonText} from '#/components/Button' import * as Dialog from '#/components/Dialog' @@ -33,7 +32,7 @@ export function ExportCarDialog({ try { setLoading(true) const did = agent.session.did - const downloadRes = await pdsAgent(agent).com.atproto.sync.getRepo({did}) + const downloadRes = await agent.com.atproto.sync.getRepo({did}) const saveRes = await saveBytesToDisk( 'repo.car', downloadRes.data, diff --git a/src/screens/SignupQueued.tsx b/src/screens/SignupQueued.tsx index 848d68f83..ad5da2a37 100644 --- a/src/screens/SignupQueued.tsx +++ b/src/screens/SignupQueued.tsx @@ -7,7 +7,6 @@ import {useLingui} from '@lingui/react' import {logger} from '#/logger' import {isSignupQueued, useAgent, useSessionApi} from '#/state/session' -import {pdsAgent} from '#/state/session/agent' import {useOnboardingDispatch} from '#/state/shell' import {Logo} from '#/view/icons/Logo' import {atoms as a, native, useBreakpoints, useTheme, web} from '#/alf' @@ -38,7 +37,7 @@ export function SignupQueued() { const checkStatus = React.useCallback(async () => { setProcessing(true) try { - const res = await pdsAgent(agent).com.atproto.temp.checkSignupQueue() + const res = await agent.com.atproto.temp.checkSignupQueue() if (res.data.activated) { // ready to go, exchange the access token for a usable one and kick off onboarding await agent.sessionManager.refreshSession() diff --git a/src/state/preferences/custom-appview-did.tsx b/src/state/preferences/custom-appview-did.tsx deleted file mode 100644 index 3a5f4aa7a..000000000 --- a/src/state/preferences/custom-appview-did.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import {isDid} from '@atproto/api' - -import {device, useStorage} from '#/storage' - -export function useCustomAppViewDid() { - const [customAppViewDid = undefined, setCustomAppViewDid] = useStorage( - device, - ['customAppViewDid'], - ) - - return [customAppViewDid, setCustomAppViewDid] as const -} - -export function readCustomAppViewDidUri() { - const maybeDid = device.get(['customAppViewDid']) - if (!maybeDid || !isDid(maybeDid)) { - return undefined - } - - return `${maybeDid}#bsky_appview` as `did:${string}:${string}#bsky_appview` -} diff --git a/src/state/queries/app-passwords.ts b/src/state/queries/app-passwords.ts index ace23ab00..12d66dd2c 100644 --- a/src/state/queries/app-passwords.ts +++ b/src/state/queries/app-passwords.ts @@ -3,7 +3,6 @@ import {useMutation, useQuery, useQueryClient} from '@tanstack/react-query' import {STALE} from '#/state/queries' import {useAgent} from '../session' -import {pdsAgent} from '../session/agent' const RQKEY_ROOT = 'app-passwords' export const RQKEY = () => [RQKEY_ROOT] @@ -14,7 +13,7 @@ export function useAppPasswordsQuery() { staleTime: STALE.MINUTES.FIVE, queryKey: RQKEY(), queryFn: async () => { - const res = await pdsAgent(agent).com.atproto.server.listAppPasswords({}) + const res = await agent.com.atproto.server.listAppPasswords({}) return res.data.passwords }, }) @@ -30,7 +29,7 @@ export function useAppPasswordCreateMutation() { >({ mutationFn: async ({name, privileged}) => { return ( - await pdsAgent(agent).com.atproto.server.createAppPassword({ + await agent.com.atproto.server.createAppPassword({ name, privileged, }) @@ -49,7 +48,7 @@ export function useAppPasswordDeleteMutation() { const agent = useAgent() return useMutation({ mutationFn: async ({name}) => { - await pdsAgent(agent).com.atproto.server.revokeAppPassword({ + await agent.com.atproto.server.revokeAppPassword({ name, }) }, diff --git a/src/state/queries/list.ts b/src/state/queries/list.ts index 73e454819..c0d5edfb1 100644 --- a/src/state/queries/list.ts +++ b/src/state/queries/list.ts @@ -17,7 +17,6 @@ import {until} from '#/lib/async/until' import {type ImageMeta} from '#/state/gallery' import {STALE} from '#/state/queries' import {useAgent, useSession} from '#/state/session' -import {pdsAgent} from '#/state/session/agent' import {invalidate as invalidateMyLists} from './my-lists' import {RQKEY as PROFILE_LISTS_RQKEY} from './profile-lists' @@ -153,7 +152,7 @@ export function useListMetadataMutation() { record.avatar = undefined } const res = ( - await pdsAgent(agent).com.atproto.repo.putRecord({ + await agent.com.atproto.repo.putRecord({ repo: currentAccount.did, collection: 'app.bsky.graph.list', rkey, @@ -232,7 +231,7 @@ export function useListDeleteMutation() { // apply in chunks for (const writesChunk of chunk(writes, 10)) { - await pdsAgent(agent).com.atproto.repo.applyWrites({ + await agent.com.atproto.repo.applyWrites({ repo: currentAccount.did, writes: writesChunk, }) diff --git a/src/state/queries/messages/actor-declaration.ts b/src/state/queries/messages/actor-declaration.ts index 4210cab3b..a5adb39d9 100644 --- a/src/state/queries/messages/actor-declaration.ts +++ b/src/state/queries/messages/actor-declaration.ts @@ -3,7 +3,6 @@ import {useMutation, useQueryClient} from '@tanstack/react-query' import {logger} from '#/logger' import {useAgent, useSession} from '#/state/session' -import {pdsAgent} from '#/state/session/agent' import {RQKEY as PROFILE_RKEY} from '../profile' export function useUpdateActorDeclaration({ @@ -20,7 +19,7 @@ export function useUpdateActorDeclaration({ return useMutation({ mutationFn: async (allowIncoming: 'all' | 'none' | 'following') => { if (!currentAccount) throw new Error('Not signed in') - const result = await pdsAgent(agent).com.atproto.repo.putRecord({ + const result = await agent.com.atproto.repo.putRecord({ repo: currentAccount.did, collection: 'chat.bsky.actor.declaration', rkey: 'self', @@ -70,7 +69,7 @@ export function useDeleteActorDeclaration() { return useMutation({ mutationFn: async () => { if (!currentAccount) throw new Error('Not signed in') - const result = await pdsAgent(agent).com.atproto.repo.deleteRecord({ + const result = await agent.api.com.atproto.repo.deleteRecord({ repo: currentAccount.did, collection: 'chat.bsky.actor.declaration', rkey: 'self', diff --git a/src/state/queries/postgate/index.ts b/src/state/queries/postgate/index.ts index 52d7459a5..92689d534 100644 --- a/src/state/queries/postgate/index.ts +++ b/src/state/queries/postgate/index.ts @@ -21,7 +21,6 @@ import { POSTGATE_COLLECTION, } from '#/state/queries/postgate/util' import {useAgent} from '#/state/session' -import {pdsAgent} from '#/state/session/agent' import * as bsky from '#/types/bsky' export async function getPostgateRecord({ @@ -97,7 +96,7 @@ export async function writePostgateRecord({ const postUrip = new AtUri(postUri) await networkRetry(2, () => - pdsAgent(agent).com.atproto.repo.putRecord({ + agent.api.com.atproto.repo.putRecord({ repo: agent.session!.did, collection: POSTGATE_COLLECTION, rkey: postUrip.rkey, diff --git a/src/state/queries/preferences/index.ts b/src/state/queries/preferences/index.ts index 74375e8c5..9daacc3a8 100644 --- a/src/state/queries/preferences/index.ts +++ b/src/state/queries/preferences/index.ts @@ -20,8 +20,7 @@ import { type ThreadViewPreferences, type UsePreferencesQueryResponse, } from '#/state/queries/preferences/types' -import {useBlankPrefAuthedAgent as useAgent} from '#/state/session' -import {pdsAgent} from '#/state/session/agent' +import {useAgent} from '#/state/session' import {saveLabelers} from '#/state/session/agent-config' import {useAgeAssurance} from '#/ageAssurance' import {makeAgeRestrictedModerationPrefs} from '#/ageAssurance/util' @@ -46,7 +45,7 @@ export function usePreferencesQuery() { if (!agent.did) { return DEFAULT_LOGGED_OUT_PREFERENCES } else { - const res = await pdsAgent(agent).getPreferences() + const res = await agent.getPreferences() // save to local storage to ensure there are labels on initial requests saveLabelers( @@ -101,7 +100,7 @@ export function useClearPreferencesMutation() { return useMutation({ mutationFn: async () => { - await pdsAgent(agent).app.bsky.actor.putPreferences({preferences: []}) + await agent.app.bsky.actor.putPreferences({preferences: []}) // triggers a refetch await queryClient.invalidateQueries({ queryKey: preferencesQueryKey, diff --git a/src/state/queries/resolve-identity.ts b/src/state/queries/resolve-identity.ts index f2409e390..74fb92404 100644 --- a/src/state/queries/resolve-identity.ts +++ b/src/state/queries/resolve-identity.ts @@ -1,68 +1,26 @@ -import {type Did, isDid} from '@atproto/api' -import {useQuery} from '@tanstack/react-query' - -import {STALE} from '.' import {LRU} from './direct-fetch-record' -const RQKEY_ROOT = 'resolve-identity' -export const RQKEY = (did: string) => [RQKEY_ROOT, did] - -// this isn't trusted... -export type DidDocument = { - '@context'?: string[] - id?: string - alsoKnownAs?: string[] - verificationMethod?: VerificationMethod[] - service?: Service[] -} - -export type VerificationMethod = { - id?: string - type?: string - controller?: string - publicKeyMultibase?: string -} - -export type Service = { - id?: string - type?: string - serviceEndpoint?: string -} -const serviceCache = new LRU() +const serviceCache = new LRU<`did:${string}`, string>() -export async function resolveDidDocument(did: Did) { +export async function resolvePdsServiceUrl(did: `did:${string}`) { return await serviceCache.getOrTryInsertWith(did, async () => { const docUrl = did.startsWith('did:plc:') ? `https://plc.directory/${did}` : `https://${did.substring(8)}/.well-known/did.json` - // TODO: we should probably validate this... - return await (await fetch(docUrl)).json() - }) -} - -export function findService(doc: DidDocument, id: string, type?: string) { - // probably not defensive enough, but we don't have atproto/did as a dep... - if (!Array.isArray(doc?.service)) return - return doc.service.find( - s => s?.serviceEndpoint && s?.id === id && (!type || s?.type === type), - ) -} - -export async function resolvePdsServiceUrl(did: Did) { - const doc = await resolveDidDocument(did) - return findService(doc, '#atproto_pds', 'AtprotoPersonalDataServer') - ?.serviceEndpoint -} - -export function useDidDocument({did}: {did: string}) { - return useQuery({ - staleTime: STALE.HOURS.ONE, - queryKey: RQKEY(did || ''), - async queryFn() { - if (!isDid(did)) return undefined - return await resolveDidDocument(did) - }, - enabled: isDid(did) && !(did.includes('#') || did.includes('?')), + // TODO: validate! + const doc: { + service: { + serviceEndpoint: string + type: string + }[] + } = await (await fetch(docUrl)).json() + const service = doc.service.find( + s => s.type === 'AtprotoPersonalDataServer', + )?.serviceEndpoint + + if (service === undefined) + throw new Error(`could not find a service for ${did}`) + return service }) } diff --git a/src/state/queries/starter-packs.ts b/src/state/queries/starter-packs.ts index 225573375..74d75814e 100644 --- a/src/state/queries/starter-packs.ts +++ b/src/state/queries/starter-packs.ts @@ -27,7 +27,6 @@ import {invalidateActorStarterPacksQuery} from '#/state/queries/actor-starter-pa import {STALE} from '#/state/queries/index' import {invalidateListMembersQuery} from '#/state/queries/list-members' import {useAgent} from '#/state/session' -import {pdsAgent} from '#/state/session/agent' import * as bsky from '#/types/bsky' const RQKEY_ROOT = 'starter-pack' @@ -204,7 +203,7 @@ export function useEditStarterPackMutation({ if (removedItems.length !== 0) { const chunks = chunk(removedItems, 50) for (const chunk of chunks) { - await pdsAgent(agent).com.atproto.repo.applyWrites({ + await agent.com.atproto.repo.applyWrites({ repo: agent.session!.did, writes: chunk.map(i => ({ $type: 'com.atproto.repo.applyWrites#delete', @@ -221,7 +220,7 @@ export function useEditStarterPackMutation({ if (addedProfiles.length > 0) { const chunks = chunk(addedProfiles, 50) for (const chunk of chunks) { - await pdsAgent(agent).com.atproto.repo.applyWrites({ + await agent.com.atproto.repo.applyWrites({ repo: agent.session!.did, writes: chunk.map(p => ({ $type: 'com.atproto.repo.applyWrites#create', @@ -238,7 +237,7 @@ export function useEditStarterPackMutation({ } const rkey = parseStarterPackUri(currentStarterPack.uri)!.rkey - await pdsAgent(agent).com.atproto.repo.putRecord({ + await agent.com.atproto.repo.putRecord({ repo: agent.session!.did, collection: 'app.bsky.graph.starterpack', rkey, diff --git a/src/state/queries/threadgate/index.ts b/src/state/queries/threadgate/index.ts index d5929c285..e760873fb 100644 --- a/src/state/queries/threadgate/index.ts +++ b/src/state/queries/threadgate/index.ts @@ -18,7 +18,6 @@ import { } from '#/state/queries/threadgate/util' import {useUpdatePostThreadThreadgateQueryCache} from '#/state/queries/usePostThread' import {useAgent} from '#/state/session' -import {pdsAgent} from '#/state/session/agent' import {useThreadgateHiddenReplyUrisAPI} from '#/state/threadgate-hidden-replies' import * as bsky from '#/types/bsky' @@ -163,7 +162,7 @@ export async function writeThreadgateRecord({ }) await networkRetry(2, () => - pdsAgent(agent).com.atproto.repo.putRecord({ + agent.api.com.atproto.repo.putRecord({ repo: agent.session!.did, collection: 'app.bsky.feed.threadgate', rkey: postUrip.rkey, diff --git a/src/state/session/agent.ts b/src/state/session/agent.ts index 17ae5790b..6ecf5af0e 100644 --- a/src/state/session/agent.ts +++ b/src/state/session/agent.ts @@ -15,7 +15,6 @@ import {type FetchHandlerOptions} from '@atproto/xrpc' import {networkRetry} from '#/lib/async/retry' import { - APPVIEW_DID_PROXY, BLUESKY_PROXY_HEADER, BSKY_SERVICE, DISCOVER_SAVED_FEED, @@ -34,7 +33,6 @@ import { setCreatedAtForDid, } from '#/ageAssurance/data' import {emitNetworkConfirmed, emitNetworkLost} from '../events' -import {readCustomAppViewDidUri} from '../preferences/custom-appview-did' import {addSessionErrorLog} from './logging' import { configureModerationForAccount, @@ -49,9 +47,7 @@ export function createPublicAgent() { configureModerationForGuest() // Side effect but only relevant for tests const agent = new BskyAppAgent({service: PUBLIC_BSKY_SERVICE}) - const proxyDid = - readCustomAppViewDidUri() || BLUESKY_PROXY_HEADER.get() || APPVIEW_DID_PROXY - agent.configureProxy(proxyDid) + agent.configureProxy(BLUESKY_PROXY_HEADER.get()) return agent } @@ -92,9 +88,7 @@ export async function createAgentAndResume( // after session is attached const aa = prefetchAgeAssuranceData({agent}) - const proxyDid = - readCustomAppViewDidUri() || BLUESKY_PROXY_HEADER.get() || APPVIEW_DID_PROXY - agent.configureProxy(proxyDid) + agent.configureProxy(BLUESKY_PROXY_HEADER.get()) return agent.prepare({ resolvers: [gates, moderation, aa], @@ -133,9 +127,7 @@ export async function createAgentAndLogin( const moderation = configureModerationForAccount(agent, account) const aa = prefetchAgeAssuranceData({agent}) - const proxyDid = - readCustomAppViewDidUri() || BLUESKY_PROXY_HEADER.get() || APPVIEW_DID_PROXY - agent.configureProxy(proxyDid) + agent.configureProxy(BLUESKY_PROXY_HEADER.get()) return agent.prepare({ resolvers: [gates, moderation, aa], @@ -242,7 +234,7 @@ export async function createAgentAndCreateAccount( }), getAge(birthDate) < 18 && networkRetry(3, () => { - return pdsAgent(agent).com.atproto.repo.putRecord({ + return agent.com.atproto.repo.putRecord({ repo: account.did, collection: 'chat.bsky.actor.declaration', rkey: 'self', @@ -307,9 +299,7 @@ export async function createAgentAndCreateAccount( logger.error(e, {message: `session: failed snoozeEmailConfirmationPrompt`}) } - const proxyDid = - readCustomAppViewDidUri() || BLUESKY_PROXY_HEADER.get() || APPVIEW_DID_PROXY - agent.configureProxy(proxyDid) + agent.configureProxy(BLUESKY_PROXY_HEADER.get()) return agent.prepare({ resolvers: [gates, moderation, aa], @@ -342,7 +332,7 @@ export function agentToSessionAccount( accessJwt: agent.session.accessJwt, signupQueued: isSignupQueued(agent.session.accessJwt), active: agent.session.active, - status: agent.session.status as SessionAccount['status'], + status: agent.session.status, pdsUrl: agent.pdsUrl?.toString(), isSelfHosted: !agent.serviceUrl.toString().startsWith(BSKY_SERVICE), } @@ -415,10 +405,6 @@ class BskyAppAgent extends BskyAgent { } }, }) - const proxyDid = readCustomAppViewDidUri() || APPVIEW_DID_PROXY - if (proxyDid) { - this.configureProxy(proxyDid) - } } async prepare({ @@ -451,12 +437,6 @@ class BskyAppAgent extends BskyAgent { this.sessionManager.session = undefined this.persistSessionHandler = undefined } - - cloneWithoutProxy(): BskyAgent { - const cloned = new BskyAgent({service: this.serviceUrl.toString()}) - cloned.sessionManager.session = this.sessionManager.session - return cloned - } } /** @@ -465,7 +445,10 @@ class BskyAppAgent extends BskyAgent { * other PDS-specific operations like preferences. */ export function pdsAgent(agent: T): T { - if ('cloneWithoutProxy' in agent && typeof agent.cloneWithoutProxy === 'function') { + if ( + 'cloneWithoutProxy' in agent && + typeof agent.cloneWithoutProxy === 'function' + ) { return agent.cloneWithoutProxy() as T } const clone = agent.clone() as T diff --git a/src/state/session/index.tsx b/src/state/session/index.tsx index 4aa4e78ee..88f2df4b8 100644 --- a/src/state/session/index.tsx +++ b/src/state/session/index.tsx @@ -1,4 +1,4 @@ -import React, {useMemo} from 'react' +import React from 'react' import {type AtpSessionEvent, type BskyAgent} from '@atproto/api' import * as persisted from '#/state/persisted' @@ -12,7 +12,6 @@ import { createAgentAndCreateAccount, createAgentAndLogin, createAgentAndResume, - pdsAgent, sessionAccountToSession, } from './agent' import {type Action, getInitialState, reducer, type State} from './reducer' @@ -249,7 +248,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) { >(async () => { const agent = state.currentAgentState.agent as BskyAppAgent const signal = cancelPendingTask() - const {data} = await pdsAgent(agent).com.atproto.server.getSession() + const {data} = await agent.com.atproto.server.getSession() if (signal.aborted) return store.dispatch({ type: 'partial-refresh-session', @@ -411,14 +410,3 @@ export function useAgent(): BskyAgent { } return agent } - -export function useBlankPrefAuthedAgent(): BskyAgent { - const agent = React.useContext(AgentContext) - if (!agent) { - throw Error('useAgent() must be below .') - } - - return useMemo(() => { - return (agent as BskyAppAgent).cloneWithoutProxy() - }, [agent]) -} diff --git a/src/storage/schema.ts b/src/storage/schema.ts index 719cb6733..65b83ae00 100644 --- a/src/storage/schema.ts +++ b/src/storage/schema.ts @@ -52,7 +52,6 @@ export type Device = { deerGateCache: string activitySubscriptionsNudged?: boolean threadgateNudged?: boolean - customAppViewDid: string | undefined /** * Policy update overlays. New IDs are required for each new announcement. diff --git a/src/view/com/modals/DeleteAccount.tsx b/src/view/com/modals/DeleteAccount.tsx index 9a0fac7f5..7ca63a8f1 100644 --- a/src/view/com/modals/DeleteAccount.tsx +++ b/src/view/com/modals/DeleteAccount.tsx @@ -18,7 +18,6 @@ import {colors, gradients, s} from '#/lib/styles' import {useTheme} from '#/lib/ThemeContext' import {useModalControls} from '#/state/modals' import {useAgent, useSession, useSessionApi} from '#/state/session' -import {pdsAgent} from '#/state/session/agent' import {atoms as a, useTheme as useNewTheme, utils} from '#/alf' import {CircleInfo_Stroke2_Corner0_Rounded as CircleInfo} from '#/components/icons/CircleInfo' import {Text as NewText} from '#/components/Typography' @@ -50,7 +49,7 @@ export function Component({}: {}) { setError('') setIsProcessing(true) try { - await pdsAgent(agent).com.atproto.server.requestAccountDelete() + await agent.com.atproto.server.requestAccountDelete() setIsEmailSent(true) } catch (e: any) { setError(cleanError(e)) @@ -77,7 +76,7 @@ export function Component({}: {}) { if (!success) { throw new Error('Failed to inform chat service of account deletion') } - await pdsAgent(agent).com.atproto.server.deleteAccount({ + await agent.com.atproto.server.deleteAccount({ did: currentAccount.did, password, token,