From 3d818adefcc4f2b646f72a9d01d84233bfd5c2cb Mon Sep 17 00:00:00 2001 From: "xan.lol" Date: Sun, 12 Apr 2026 17:34:22 -0700 Subject: [PATCH] fix: getPreferences/putPreferences pls don't fail (and more pdsAgent) --- patches/@atproto+api+0.19.6.patch | 16 +++++++++++++--- src/ageAssurance/data.tsx | 3 ++- src/features/liveEvents/preferences.ts | 5 +++-- src/screens/Onboarding/StepFinished/index.tsx | 3 ++- src/screens/Settings/InterestsSettings.tsx | 3 ++- src/screens/Settings/Settings.tsx | 3 ++- src/state/birthdate.ts | 3 ++- src/state/queries/labeler.ts | 5 +++-- src/state/queries/notifications/settings.ts | 5 ++++- src/state/queries/nuxs/index.ts | 3 ++- src/state/queries/post-interaction-settings.ts | 3 ++- src/state/session/agent.ts | 4 ++-- 12 files changed, 39 insertions(+), 17 deletions(-) diff --git a/patches/@atproto+api+0.19.6.patch b/patches/@atproto+api+0.19.6.patch index aed3889a7..597d3ff89 100644 --- a/patches/@atproto+api+0.19.6.patch +++ b/patches/@atproto+api+0.19.6.patch @@ -1,8 +1,18 @@ diff --git a/node_modules/@atproto/api/dist/agent.js b/node_modules/@atproto/api/dist/agent.js -index 634e463..57b5c74 100644 +index c486fb7..d77a845 100644 --- a/node_modules/@atproto/api/dist/agent.js +++ b/node_modules/@atproto/api/dist/agent.js -@@ -593,7 +593,7 @@ class Agent extends xrpc_1.XrpcClient { +@@ -99,6 +99,9 @@ class Agent extends xrpc_1.XrpcClient { + if (this.proxy && !headers.has('atproto-proxy')) { + headers.set('atproto-proxy', this.proxy); + } ++ if (headers.get('atproto-proxy') === '') { ++ headers.delete('atproto-proxy'); ++ } + // Merge the labelers header of this particular request with the app & + // instance labelers. + headers.set('atproto-accept-labelers', [ +@@ -597,7 +600,7 @@ class Agent extends xrpc_1.XrpcClient { hideAllFeeds: false, }, }; @@ -11,7 +21,7 @@ index 634e463..57b5c74 100644 const labelPrefs = []; for (const pref of res.data.preferences) { if (predicate.isValidAdultContentPref(pref)) { -@@ -1275,14 +1275,14 @@ class Agent extends xrpc_1.XrpcClient { +@@ -1279,14 +1282,14 @@ class Agent extends xrpc_1.XrpcClient { async updatePreferences(cb) { try { await __classPrivateFieldGet(this, _Agent_prefsLock, "f").acquireAsync(); diff --git a/src/ageAssurance/data.tsx b/src/ageAssurance/data.tsx index a0890747f..a3e06cdd0 100644 --- a/src/ageAssurance/data.tsx +++ b/src/ageAssurance/data.tsx @@ -19,6 +19,7 @@ import { snoozeBirthdateUpdateAllowedForDid, } from '#/state/birthdate' import {useAgent, useSession} from '#/state/session' +import {pdsAgent} from '#/state/session/agent' import * as debug from '#/ageAssurance/debug' import {logger} from '#/ageAssurance/logger' import { @@ -324,7 +325,7 @@ export async function getOtherRequiredData({ agent: AtpAgent }): Promise { if (debug.enabled) return debug.resolve(debug.otherRequiredData) - const [prefs] = await Promise.all([agent.getPreferences()]) + const [prefs] = await Promise.all([pdsAgent(agent).getPreferences()]) const data: OtherRequiredData = { birthdate: prefs.birthDate ? prefs.birthDate.toISOString() : undefined, } diff --git a/src/features/liveEvents/preferences.ts b/src/features/liveEvents/preferences.ts index f3a05bbb5..52464a84c 100644 --- a/src/features/liveEvents/preferences.ts +++ b/src/features/liveEvents/preferences.ts @@ -7,6 +7,7 @@ import { usePreferencesQuery, } from '#/state/queries/preferences' import {useAgent} from '#/state/session' +import {pdsAgent} from '#/state/session/agent' import {useAnalytics} from '#/analytics' import {IS_WEB} from '#/env' import * as env from '#/env' @@ -46,7 +47,7 @@ function useWebOnlyDebugLiveEventPreferences() { window.__updateLiveEventPreferences = async ( action: LiveEventPreferencesAction, ) => { - await agent.updateLiveEventPreferences(action) + await pdsAgent(agent).updateLiveEventPreferences(action) // triggers a refetch await queryClient.invalidateQueries({ queryKey: preferencesQueryKey, @@ -108,7 +109,7 @@ export function useUpdateLiveEventPreferences(props: { } }, mutationFn: async action => { - const updated = await agent.updateLiveEventPreferences(action) + const updated = await pdsAgent(agent).updateLiveEventPreferences(action) const prefs = updated.find(p => asPredicate(AppBskyActorDefs.validateLiveEventPreferences)(p), ) diff --git a/src/screens/Onboarding/StepFinished/index.tsx b/src/screens/Onboarding/StepFinished/index.tsx index e477528f1..e62160872 100644 --- a/src/screens/Onboarding/StepFinished/index.tsx +++ b/src/screens/Onboarding/StepFinished/index.tsx @@ -27,6 +27,7 @@ import {getAllListMembers} from '#/state/queries/list-members' import {preferencesQueryKey} from '#/state/queries/preferences' import {RQKEY as profileRQKey} from '#/state/queries/profile' import {useAgent} from '#/state/session' +import {pdsAgent} from '#/state/session/agent' import {useOnboardingDispatch} from '#/state/shell' import {useProgressGuideControls} from '#/state/shell/progress-guide' import { @@ -106,7 +107,7 @@ export function StepFinished() { ), (async () => { // Interests need to get saved first, then we can write the feeds to prefs - await agent.setInterestsPref({tags: selectedInterests}) + await pdsAgent(agent).setInterestsPref({tags: selectedInterests}) // Default feeds that every user should have pinned when landing in the app const feedsToSave: AppBskyActorDefs.SavedFeed[] = [ diff --git a/src/screens/Settings/InterestsSettings.tsx b/src/screens/Settings/InterestsSettings.tsx index 17c493c23..5261e2c04 100644 --- a/src/screens/Settings/InterestsSettings.tsx +++ b/src/screens/Settings/InterestsSettings.tsx @@ -25,6 +25,7 @@ import {createGetSuggestedUsersForExploreQueryKey} from '#/state/queries/trendin import {createGetSuggestedUsersForSeeMoreQueryKey} from '#/state/queries/trending/useGetSuggestedUsersForSeeMoreQuery' import {createSuggestedStarterPacksQueryKey} from '#/state/queries/useSuggestedStarterPacksQuery' import {useAgent} from '#/state/session' +import {pdsAgent} from '#/state/session/agent' import {atoms as a, useGutters, useTheme} from '#/alf' import {Admonition} from '#/components/Admonition' import {Divider} from '#/components/Divider' @@ -111,7 +112,7 @@ function Inner({ setIsSaving(true) try { - await agent.setInterestsPref({tags: interests}) + await pdsAgent(agent).setInterestsPref({tags: interests}) qc.setQueriesData( {queryKey: preferencesQueryKey}, (old?: UsePreferencesQueryResponse) => { diff --git a/src/screens/Settings/Settings.tsx b/src/screens/Settings/Settings.tsx index f4b55bf9c..a69b579db 100644 --- a/src/screens/Settings/Settings.tsx +++ b/src/screens/Settings/Settings.tsx @@ -26,6 +26,7 @@ import {useDeleteActorDeclaration} from '#/state/queries/messages/actor-declarat import {useProfileQuery, useProfilesQuery} from '#/state/queries/profile' import {useAgent} from '#/state/session' import {type SessionAccount, useSession, useSessionApi} from '#/state/session' +import {pdsAgent} from '#/state/session/agent' import {useOnboardingDispatch} from '#/state/shell' import {useLoggedOutViewControls} from '#/state/shell/logged-out' import {useCloseAllActiveElements} from '#/state/util' @@ -553,7 +554,7 @@ function DevOptions() {