+1
-1
src/state/queries/preferences/index.ts
+1
-1
src/state/queries/preferences/index.ts
···
22
22
type ThreadViewPreferences,
23
23
type UsePreferencesQueryResponse,
24
24
} from '#/state/queries/preferences/types'
25
-
import {useAgent} from '#/state/session'
25
+
import {useBlankPrefAuthedAgent as useAgent} from '#/state/session'
26
26
import {saveLabelers} from '#/state/session/agent-config'
27
27
28
28
export * from '#/state/queries/preferences/const'
+6
src/state/session/agent.ts
+6
src/state/session/agent.ts
···
348
348
this.sessionManager.session = undefined
349
349
this.persistSessionHandler = undefined
350
350
}
351
+
352
+
cloneWithoutProxy(): BskyAgent {
353
+
const cloned = new BskyAgent({service: this.serviceUrl.toString()})
354
+
cloned.sessionManager.session = this.sessionManager.session
355
+
return cloned
356
+
}
351
357
}
352
358
353
359
export type {BskyAppAgent}
+12
-1
src/state/session/index.tsx
+12
-1
src/state/session/index.tsx
···
1
-
import React from 'react'
1
+
import React, {useMemo} from 'react'
2
2
import {type AtpSessionEvent, type BskyAgent} from '@atproto/api'
3
3
4
4
import {isWeb} from '#/platform/detection'
···
390
390
}
391
391
return agent
392
392
}
393
+
394
+
export function useBlankPrefAuthedAgent(): BskyAgent {
395
+
const agent = React.useContext(AgentContext)
396
+
if (!agent) {
397
+
throw Error('useAgent() must be below <SessionProvider>.')
398
+
}
399
+
400
+
return useMemo(() => {
401
+
return (agent as BskyAppAgent).cloneWithoutProxy()
402
+
}, [agent])
403
+
}