Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: getPreferences/putPreferences pls don't fail (and more pdsAgent)

xan.lol 3d818ade 66a69d84

+39 -17
+13 -3
patches/@atproto+api+0.19.6.patch
··· 1 1 diff --git a/node_modules/@atproto/api/dist/agent.js b/node_modules/@atproto/api/dist/agent.js 2 - index 634e463..57b5c74 100644 2 + index c486fb7..d77a845 100644 3 3 --- a/node_modules/@atproto/api/dist/agent.js 4 4 +++ b/node_modules/@atproto/api/dist/agent.js 5 - @@ -593,7 +593,7 @@ class Agent extends xrpc_1.XrpcClient { 5 + @@ -99,6 +99,9 @@ class Agent extends xrpc_1.XrpcClient { 6 + if (this.proxy && !headers.has('atproto-proxy')) { 7 + headers.set('atproto-proxy', this.proxy); 8 + } 9 + + if (headers.get('atproto-proxy') === '') { 10 + + headers.delete('atproto-proxy'); 11 + + } 12 + // Merge the labelers header of this particular request with the app & 13 + // instance labelers. 14 + headers.set('atproto-accept-labelers', [ 15 + @@ -597,7 +600,7 @@ class Agent extends xrpc_1.XrpcClient { 6 16 hideAllFeeds: false, 7 17 }, 8 18 }; ··· 11 21 const labelPrefs = []; 12 22 for (const pref of res.data.preferences) { 13 23 if (predicate.isValidAdultContentPref(pref)) { 14 - @@ -1275,14 +1275,14 @@ class Agent extends xrpc_1.XrpcClient { 24 + @@ -1279,14 +1282,14 @@ class Agent extends xrpc_1.XrpcClient { 15 25 async updatePreferences(cb) { 16 26 try { 17 27 await __classPrivateFieldGet(this, _Agent_prefsLock, "f").acquireAsync();
+2 -1
src/ageAssurance/data.tsx
··· 19 19 snoozeBirthdateUpdateAllowedForDid, 20 20 } from '#/state/birthdate' 21 21 import {useAgent, useSession} from '#/state/session' 22 + import {pdsAgent} from '#/state/session/agent' 22 23 import * as debug from '#/ageAssurance/debug' 23 24 import {logger} from '#/ageAssurance/logger' 24 25 import { ··· 324 325 agent: AtpAgent 325 326 }): Promise<OtherRequiredData> { 326 327 if (debug.enabled) return debug.resolve(debug.otherRequiredData) 327 - const [prefs] = await Promise.all([agent.getPreferences()]) 328 + const [prefs] = await Promise.all([pdsAgent(agent).getPreferences()]) 328 329 const data: OtherRequiredData = { 329 330 birthdate: prefs.birthDate ? prefs.birthDate.toISOString() : undefined, 330 331 }
+3 -2
src/features/liveEvents/preferences.ts
··· 7 7 usePreferencesQuery, 8 8 } from '#/state/queries/preferences' 9 9 import {useAgent} from '#/state/session' 10 + import {pdsAgent} from '#/state/session/agent' 10 11 import {useAnalytics} from '#/analytics' 11 12 import {IS_WEB} from '#/env' 12 13 import * as env from '#/env' ··· 46 47 window.__updateLiveEventPreferences = async ( 47 48 action: LiveEventPreferencesAction, 48 49 ) => { 49 - await agent.updateLiveEventPreferences(action) 50 + await pdsAgent(agent).updateLiveEventPreferences(action) 50 51 // triggers a refetch 51 52 await queryClient.invalidateQueries({ 52 53 queryKey: preferencesQueryKey, ··· 108 109 } 109 110 }, 110 111 mutationFn: async action => { 111 - const updated = await agent.updateLiveEventPreferences(action) 112 + const updated = await pdsAgent(agent).updateLiveEventPreferences(action) 112 113 const prefs = updated.find(p => 113 114 asPredicate(AppBskyActorDefs.validateLiveEventPreferences)(p), 114 115 )
+2 -1
src/screens/Onboarding/StepFinished/index.tsx
··· 27 27 import {preferencesQueryKey} from '#/state/queries/preferences' 28 28 import {RQKEY as profileRQKey} from '#/state/queries/profile' 29 29 import {useAgent} from '#/state/session' 30 + import {pdsAgent} from '#/state/session/agent' 30 31 import {useOnboardingDispatch} from '#/state/shell' 31 32 import {useProgressGuideControls} from '#/state/shell/progress-guide' 32 33 import { ··· 106 107 ), 107 108 (async () => { 108 109 // Interests need to get saved first, then we can write the feeds to prefs 109 - await agent.setInterestsPref({tags: selectedInterests}) 110 + await pdsAgent(agent).setInterestsPref({tags: selectedInterests}) 110 111 111 112 // Default feeds that every user should have pinned when landing in the app 112 113 const feedsToSave: AppBskyActorDefs.SavedFeed[] = [
+2 -1
src/screens/Settings/InterestsSettings.tsx
··· 25 25 import {createGetSuggestedUsersForSeeMoreQueryKey} from '#/state/queries/trending/useGetSuggestedUsersForSeeMoreQuery' 26 26 import {createSuggestedStarterPacksQueryKey} from '#/state/queries/useSuggestedStarterPacksQuery' 27 27 import {useAgent} from '#/state/session' 28 + import {pdsAgent} from '#/state/session/agent' 28 29 import {atoms as a, useGutters, useTheme} from '#/alf' 29 30 import {Admonition} from '#/components/Admonition' 30 31 import {Divider} from '#/components/Divider' ··· 111 112 setIsSaving(true) 112 113 113 114 try { 114 - await agent.setInterestsPref({tags: interests}) 115 + await pdsAgent(agent).setInterestsPref({tags: interests}) 115 116 qc.setQueriesData( 116 117 {queryKey: preferencesQueryKey}, 117 118 (old?: UsePreferencesQueryResponse) => {
+2 -1
src/screens/Settings/Settings.tsx
··· 26 26 import {useProfileQuery, useProfilesQuery} from '#/state/queries/profile' 27 27 import {useAgent} from '#/state/session' 28 28 import {type SessionAccount, useSession, useSessionApi} from '#/state/session' 29 + import {pdsAgent} from '#/state/session/agent' 29 30 import {useOnboardingDispatch} from '#/state/shell' 30 31 import {useLoggedOutViewControls} from '#/state/shell/logged-out' 31 32 import {useCloseAllActiveElements} from '#/state/util' ··· 553 554 <Button 554 555 onPress={() => { 555 556 device.set([PolicyUpdate202508], false) 556 - void agent.bskyAppRemoveNuxs([PolicyUpdate202508]) 557 + void pdsAgent(agent).bskyAppRemoveNuxs([PolicyUpdate202508]) 557 558 Toast.show(`Done`, { 558 559 type: 'info', 559 560 })
+2 -1
src/state/birthdate.ts
··· 6 6 import {usePatchAgeAssuranceOtherRequiredData} from '#/ageAssurance' 7 7 import {IS_DEV} from '#/env' 8 8 import {account} from '#/storage' 9 + import {pdsAgent} from './session/agent' 9 10 10 11 // 6s in dev, 48h in prod 11 12 const BIRTHDATE_DELAY_HOURS = IS_DEV ? 0.001 : 48 ··· 58 59 return useMutation<void, unknown, {birthDate: Date}>({ 59 60 mutationFn: async ({birthDate}: {birthDate: Date}) => { 60 61 const bday = birthDate.toISOString() 61 - await agent.setPersonalDetails({birthDate: bday}) 62 + await pdsAgent(agent).setPersonalDetails({birthDate: bday}) 62 63 // triggers a refetch 63 64 await queryClient.invalidateQueries({ 64 65 queryKey: preferencesQueryKey,
+3 -2
src/state/queries/labeler.ts
··· 10 10 } from '#/state/queries/preferences' 11 11 import {createQueryKey} from '#/state/queries/util' 12 12 import {useAgent} from '#/state/session' 13 + import {pdsAgent} from '../session/agent' 13 14 14 15 const labelerInfoQueryKeyRoot = 'labeler-info' 15 16 export const labelerInfoQueryKey = (did: string) => [ ··· 144 145 if (labelerCount >= MAX_LABELERS) { 145 146 throw new Error('MAX_LABELERS') 146 147 } 147 - await agent.addLabeler(did) 148 + await pdsAgent(agent).addLabeler(did) 148 149 } else { 149 - await agent.removeLabeler(did) 150 + await pdsAgent(agent).removeLabeler(did) 150 151 } 151 152 }, 152 153 async onSuccess() {
+4 -1
src/state/queries/notifications/settings.ts
··· 22 22 return useQuery({ 23 23 queryKey: RQKEY, 24 24 queryFn: async () => { 25 - const response = await agent.app.bsky.notification.getPreferences() 25 + const response = await agent.app.bsky.notification.getPreferences( 26 + {}, 27 + {headers: {'atproto-proxy': ''}}, 28 + ) 26 29 return response.data.preferences 27 30 }, 28 31 enabled,
+2 -1
src/state/queries/nuxs/index.ts
··· 7 7 usePreferencesQuery, 8 8 } from '#/state/queries/preferences' 9 9 import {useAgent} from '#/state/session' 10 + import {pdsAgent} from '#/state/session/agent' 10 11 11 12 export {Nux} from '#/state/queries/nuxs/definitions' 12 13 ··· 102 103 return useMutation({ 103 104 retry: 3, 104 105 mutationFn: async (nux: AppNux) => { 105 - await agent.bskyAppUpsertNux(serializeAppNux(nux)) 106 + await pdsAgent(agent).bskyAppUpsertNux(serializeAppNux(nux)) 106 107 // triggers a refetch 107 108 await queryClient.invalidateQueries({ 108 109 queryKey: preferencesQueryKey,
+2 -1
src/state/queries/post-interaction-settings.ts
··· 3 3 4 4 import {preferencesQueryKey} from '#/state/queries/preferences' 5 5 import {useAgent} from '#/state/session' 6 + import {pdsAgent} from '../session/agent' 6 7 7 8 export function usePostInteractionSettingsMutation({ 8 9 onError, ··· 15 16 const agent = useAgent() 16 17 return useMutation({ 17 18 async mutationFn(props: AppBskyActorDefs.PostInteractionSettingsPref) { 18 - await agent.setPostInteractionSettings(props) 19 + await pdsAgent(agent).setPostInteractionSettings(props) 19 20 }, 20 21 async onSuccess() { 21 22 await qc.invalidateQueries({
+2 -2
src/state/session/agent.ts
··· 191 191 if (IS_PROD_SERVICE(service)) { 192 192 void Promise.allSettled([ 193 193 networkRetry(3, () => { 194 - return agent.setPersonalDetails({ 194 + return pdsAgent(agent).setPersonalDetails({ 195 195 birthDate: birthdate, 196 196 }) 197 197 }).catch(e => { ··· 257 257 } else { 258 258 void Promise.allSettled([ 259 259 networkRetry(3, () => { 260 - return agent.setPersonalDetails({ 260 + return pdsAgent(agent).setPersonalDetails({ 261 261 birthDate: birthDate.toISOString(), 262 262 }) 263 263 }).catch(e => {