migrate the thread mute backfill to the appview client
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Vendored
+10
-5
@@ -5,9 +5,11 @@ import {
|
|||||||
useEffect,
|
useEffect,
|
||||||
useState,
|
useState,
|
||||||
} from 'react'
|
} from 'react'
|
||||||
|
import {type AtUriString} from '@atproto/syntax'
|
||||||
|
|
||||||
import * as persisted from '#/state/persisted'
|
import * as persisted from '#/state/persisted'
|
||||||
import {useAgent, useSession} from '../session'
|
import {app} from '#/lexicons'
|
||||||
|
import {useAppviewClient, useSession} from '../session'
|
||||||
|
|
||||||
type StateContext = Map<string, boolean>
|
type StateContext = Map<string, boolean>
|
||||||
type SetStateContext = (uri: string, value: boolean) => void
|
type SetStateContext = (uri: string, value: boolean) => void
|
||||||
@@ -56,7 +58,7 @@ export function useSetThreadMute() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function useMigrateMutes(setThreadMute: SetStateContext) {
|
function useMigrateMutes(setThreadMute: SetStateContext) {
|
||||||
const agent = useAgent()
|
const client = useAppviewClient()
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -87,8 +89,11 @@ function useMigrateMutes(setThreadMute: SetStateContext) {
|
|||||||
|
|
||||||
setThreadMute(root, true)
|
setThreadMute(root, true)
|
||||||
|
|
||||||
await agent.api.app.bsky.graph
|
await client
|
||||||
.muteThread({root})
|
.call(app.bsky.graph.muteThread, {
|
||||||
|
// the persisted list only ever holds post at-uris
|
||||||
|
root: root as AtUriString,
|
||||||
|
})
|
||||||
// not a big deal if this fails, since the post might have been deleted
|
// not a big deal if this fails, since the post might have been deleted
|
||||||
.catch(console.error)
|
.catch(console.error)
|
||||||
}
|
}
|
||||||
@@ -100,5 +105,5 @@ function useMigrateMutes(setThreadMute: SetStateContext) {
|
|||||||
cancelled = true
|
cancelled = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, [agent, currentAccount, setThreadMute])
|
}, [client, currentAccount, setThreadMute])
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user