migrate the remaining agent reads outside the session layer
The last non-session `useAgent` consumers, all thin aliases over calls the clients already make: - `handle.ts`: `getProfile` / `resolveHandle` to the appview client. - `post.ts`: the three post readers share one `fetchPost` helper on the appview client. Their consumers still want `@atproto/api` views, so the generated view is asserted across at that single boundary rather than at each call site. - `post-feed.ts`: `agent.session` gated the logged-out "did any post survive moderation" assertion, which is a question about the session, not the transport - it reads `hasSession` from the session context now. - `ChangeHandleDialog`: `agent.serviceUrl` becomes `currentAccount.service`. - `TestCtrls.e2e`: drops the `configureProxy` call. The appview client reads `BLUESKY_PROXY_HEADER` when the bundle builds it, and the gate around this input means no bundle exists yet, so setting the constant is sufficient. `preferences/index.ts` still writes labeler subscriptions to the agent; that one moves with the bundle rework, which is what gives it a client to write to. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,7 @@ import {LogBox, Pressable, TextInput, View} from 'react-native'
|
||||
import {useQueryClient} from '@tanstack/react-query'
|
||||
|
||||
import {BLUESKY_PROXY_HEADER} from '#/lib/constants'
|
||||
import {useAgent, useSessionApi} from '#/state/session'
|
||||
import {useSessionApi} from '#/state/session'
|
||||
import {useLoggedOutViewControls} from '#/state/shell/logged-out'
|
||||
import {useOnboardingDispatch} from '#/state/shell/onboarding'
|
||||
import {navigate} from '../../../Navigation'
|
||||
@@ -31,7 +31,6 @@ const BTN = {height: 1, width: 1, backgroundColor: 'red'}
|
||||
let hasConfiguredProxy = false
|
||||
|
||||
export function TestCtrls() {
|
||||
const agent = useAgent()
|
||||
const queryClient = useQueryClient()
|
||||
const {logoutEveryAccount, login} = useSessionApi()
|
||||
const onboardingDispatch = useOnboardingDispatch()
|
||||
@@ -74,8 +73,13 @@ export function TestCtrls() {
|
||||
autoCapitalize="none"
|
||||
onSubmitEditing={() => {
|
||||
const header = `${proxyHeader}#bsky_appview`
|
||||
/*
|
||||
* The appview client reads `BLUESKY_PROXY_HEADER.get()` when the
|
||||
* bundle builds it (see clients.ts), so setting the mutable constant
|
||||
* retargets the proxy for the sign-ins below without reconfiguring
|
||||
* anything: the gate above means no bundle exists yet.
|
||||
*/
|
||||
BLUESKY_PROXY_HEADER.set(header)
|
||||
agent.configureProxy(header as any)
|
||||
hasConfiguredProxy = true
|
||||
setIsProxyConfigured(true)
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user