From 305a3573cdedbdadcf8a2b5e28b3aea4aa6d8380 Mon Sep 17 00:00:00 2001 From: xan.lol Date: Fri, 17 Jul 2026 04:21:57 +0000 Subject: [PATCH] make moderation labelers work with custom appview? --- src/state/queries/labeler.ts | 16 +++++++++------- src/state/queries/preferences/index.ts | 14 +++++++++++--- src/state/session/agent.ts | 4 ++-- 3 file(s) changed, 22 insertion(s)(+), 12 deletion(s)(-) diff --git a/src/state/queries/labeler.ts b/src/state/queries/labeler.ts --- a/src/state/queries/labeler.ts +++ b/src/state/queries/labeler.ts @@ -88,7 +88,8 @@ const agent = useAgent() return useMutation({ async mutationFn({dids}: {dids: string[]}) { - await Promise.all(dids.map(did => agent.removeLabeler(did))) + const directAgent = pdsAgent(agent) + await Promise.all(dids.map(did => directAgent.removeLabeler(did))) }, async onSuccess() { await queryClient.invalidateQueries({ @@ -123,6 +124,7 @@ */ const labelerDids = ( preferences.data?.moderationPrefs?.labelers ?? [] ).map(l => l.did) + const directAgent = pdsAgent(agent) const invalidLabelers: string[] = [] if (labelerDids.length) { const profiles = await agent.getProfiles({actors: labelerDids}) @@ -142,7 +144,9 @@ } } } if (invalidLabelers.length) { - await Promise.all(invalidLabelers.map(did => agent.removeLabeler(did))) + await Promise.all( + invalidLabelers.map(did => directAgent.removeLabeler(did)), + ) } if (subscribe) { @@ -153,16 +157,14 @@ const labelerCount = labelerDids.length - invalidLabelers.length if (labelerCount >= MAX_LABELERS) { throw new Error('MAX_LABELERS') } - await pdsAgent(agent).addLabeler(did) + await directAgent.addLabeler(did) } } else { if (isAppLabeler(did)) { addIgnoredAppLabeler(did) - await pdsAgent(agent) - .removeLabeler(did) - .catch(() => {}) + await directAgent.removeLabeler(did).catch(() => {}) } else { - await pdsAgent(agent).removeLabeler(did) + await directAgent.removeLabeler(did) } } }, diff --git a/src/state/queries/preferences/index.ts b/src/state/queries/preferences/index.ts --- a/src/state/queries/preferences/index.ts +++ b/src/state/queries/preferences/index.ts @@ -138,7 +138,11 @@ unknown, {label: string; visibility: LabelPreference; labelerDid: string | undefined} >({ mutationFn: async ({label, visibility, labelerDid}) => { - await agent.setContentLabelPref(label, visibility, labelerDid) + await pdsAgent(agent).setContentLabelPref( + label, + visibility, + labelerDid, + ) ax.metric('moderation:changeLabelPreference', {preference: visibility}) // triggers a refetch await queryClient.invalidateQueries({ @@ -162,7 +166,11 @@ label: string visibility: LabelPreference labelerDid?: string }) => { - await agent.setContentLabelPref(label, visibility, labelerDid) + await pdsAgent(agent).setContentLabelPref( + label, + visibility, + labelerDid, + ) // triggers a refetch await queryClient.invalidateQueries({ queryKey: preferencesQueryKey, @@ -177,7 +185,7 @@ const agent = useAgent() return useMutation({ mutationFn: async ({enabled}) => { - await agent.setAdultContentEnabled(enabled) + await pdsAgent(agent).setAdultContentEnabled(enabled) // triggers a refetch await queryClient.invalidateQueries({ queryKey: preferencesQueryKey, diff --git a/src/state/session/agent.ts b/src/state/session/agent.ts --- a/src/state/session/agent.ts +++ b/src/state/session/agent.ts @@ -439,8 +439,8 @@ this.persistSessionHandler = undefined } cloneWithoutProxy(): AtpAgent { - const cloned = new AtpAgent({service: this.serviceUrl.toString()}) - cloned.sessionManager.session = this.sessionManager.session + const cloned = this.clone() + cloned.configureProxy(null) return cloned } } -- tangled.sh