[🐴] Swap in new package, update usages (#3992)

* Swap in new package, update usages

* Remove uneccessary patch

* Override type in safe place
This commit is contained in:
Eric Bailey
2024-05-14 09:22:09 -05:00
committed by GitHub
parent 107760d551
commit 9173be686c
22 changed files with 79 additions and 173 deletions
@@ -1,15 +1,14 @@
import {
BskyAgent,
ChatBskyConvoDefs,
ChatBskyConvoListConvos,
ChatBskyConvoMuteConvo,
} from '@atproto-labs/api'
} from '@atproto/api'
import {InfiniteData, useMutation, useQueryClient} from '@tanstack/react-query'
import {useDmServiceUrlStorage} from '#/screens/Messages/Temp/useDmServiceUrlStorage'
import {DM_SERVICE_HEADERS} from '#/state/queries/messages/const'
import {useAgent} from '#/state/session'
import {RQKEY as CONVO_KEY} from './conversation'
import {RQKEY as CONVO_LIST_KEY} from './list-converations'
import {useHeaders} from './temp-headers'
export function useMuteConvo(
convoId: string | undefined,
@@ -22,24 +21,23 @@ export function useMuteConvo(
},
) {
const queryClient = useQueryClient()
const headers = useHeaders()
const {serviceUrl} = useDmServiceUrlStorage()
const {getAgent} = useAgent()
return useMutation({
mutationFn: async ({mute}: {mute: boolean}) => {
if (!convoId) throw new Error('No convoId provided')
const agent = new BskyAgent({service: serviceUrl})
const agent = getAgent()
if (mute) {
const {data} = await agent.api.chat.bsky.convo.muteConvo(
{convoId},
{headers, encoding: 'application/json'},
{headers: DM_SERVICE_HEADERS, encoding: 'application/json'},
)
return data
} else {
const {data} = await agent.api.chat.bsky.convo.unmuteConvo(
{convoId},
{headers, encoding: 'application/json'},
{headers: DM_SERVICE_HEADERS, encoding: 'application/json'},
)
return data
}