Bluesky app fork with some witchin' additions ๐Ÿ’ซ

[๐Ÿด] Swap in new package, update usages (#3992)

* Swap in new package, update usages

* Remove uneccessary patch

* Override type in safe place

authored by

Eric Bailey and committed by
GitHub
9173be68 107760d5

+79 -173
+1 -2
package.json
··· 49 49 "open-analyzer": "EXPO_PUBLIC_OPEN_ANALYZER=1 yarn build-web" 50 50 }, 51 51 "dependencies": { 52 - "@atproto-labs/api": "^0.12.8-clipclops.0", 53 - "@atproto/api": "^0.12.9", 52 + "@atproto/api": "^0.12.10", 54 53 "@bam.tech/react-native-image-resizer": "^3.0.4", 55 54 "@braintree/sanitize-url": "^6.0.2", 56 55 "@discord/bottom-sheet": "bluesky-social/react-native-bottom-sheet",
+1 -1
src/components/dms/ActionsWrapper.tsx
··· 7 7 useSharedValue, 8 8 withTiming, 9 9 } from 'react-native-reanimated' 10 - import {ChatBskyConvoDefs} from '@atproto-labs/api' 10 + import {ChatBskyConvoDefs} from '@atproto/api' 11 11 12 12 import {HITSLOP_10} from 'lib/constants' 13 13 import {useHaptics} from 'lib/haptics'
+1 -1
src/components/dms/ActionsWrapper.web.tsx
··· 1 1 import React from 'react' 2 2 import {StyleSheet, View} from 'react-native' 3 - import {ChatBskyConvoDefs} from '@atproto-labs/api' 3 + import {ChatBskyConvoDefs} from '@atproto/api' 4 4 5 5 import {atoms as a} from '#/alf' 6 6 import {MessageMenu} from '#/components/dms/MessageMenu'
+2 -4
src/components/dms/ConvoMenu.tsx
··· 1 1 import React, {useCallback} from 'react' 2 2 import {Keyboard, Pressable, View} from 'react-native' 3 - import {AppBskyActorDefs} from '@atproto/api' 4 - import {ChatBskyConvoDefs} from '@atproto-labs/api' 5 - import {ConvoView} from '@atproto-labs/api/dist/client/types/chat/bsky/convo/defs' 3 + import {AppBskyActorDefs, ChatBskyConvoDefs} from '@atproto/api' 6 4 import {msg, Trans} from '@lingui/macro' 7 5 import {useLingui} from '@lingui/react' 8 6 import {useNavigation} from '@react-navigation/native' ··· 37 35 hideTrigger, 38 36 triggerOpacity, 39 37 }: { 40 - convo: ConvoView 38 + convo: ChatBskyConvoDefs.ConvoView 41 39 profile: AppBskyActorDefs.ProfileViewBasic 42 40 onUpdateConvo?: (convo: ChatBskyConvoDefs.ConvoView) => void 43 41 control?: Menu.MenuControlProps
+1 -2
src/components/dms/MessageItem.tsx
··· 1 1 import React, {useCallback, useMemo, useRef} from 'react' 2 2 import {LayoutAnimation, StyleProp, TextStyle, View} from 'react-native' 3 - import {RichText as RichTextAPI} from '@atproto/api' 4 - import {ChatBskyConvoDefs} from '@atproto-labs/api' 3 + import {ChatBskyConvoDefs, RichText as RichTextAPI} from '@atproto/api' 5 4 import {msg} from '@lingui/macro' 6 5 import {useLingui} from '@lingui/react' 7 6
+1 -2
src/components/dms/MessageMenu.tsx
··· 1 1 import React from 'react' 2 2 import {LayoutAnimation, Pressable, View} from 'react-native' 3 3 import * as Clipboard from 'expo-clipboard' 4 - import {RichText} from '@atproto/api' 5 - import {ChatBskyConvoDefs} from '@atproto-labs/api' 4 + import {ChatBskyConvoDefs, RichText} from '@atproto/api' 6 5 import {msg} from '@lingui/macro' 7 6 import {useLingui} from '@lingui/react' 8 7
+2 -2
src/components/dms/MessageReportDialog.tsx
··· 1 1 import React, {memo, useMemo, useState} from 'react' 2 2 import {View} from 'react-native' 3 - import {RichText as RichTextAPI} from '@atproto/api' 4 3 import { 5 4 ChatBskyConvoDefs, 6 5 ComAtprotoModerationCreateReport, 7 - } from '@atproto-labs/api' 6 + RichText as RichTextAPI, 7 + } from '@atproto/api' 8 8 import {msg, Trans} from '@lingui/macro' 9 9 import {useLingui} from '@lingui/react' 10 10 import {useMutation} from '@tanstack/react-query'
+1 -1
src/screens/Messages/List/index.tsx
··· 1 1 import React, {useCallback, useMemo, useState} from 'react' 2 2 import {View} from 'react-native' 3 - import {ChatBskyConvoDefs} from '@atproto-labs/api' 3 + import {ChatBskyConvoDefs} from '@atproto/api' 4 4 import {msg, Trans} from '@lingui/macro' 5 5 import {useLingui} from '@lingui/react' 6 6 import {useNavigation} from '@react-navigation/native'
+17 -41
src/state/messages/convo/agent.ts
··· 1 - import {AppBskyActorDefs} from '@atproto/api' 2 1 import { 2 + AppBskyActorDefs, 3 3 BskyAgent, 4 4 ChatBskyConvoDefs, 5 5 ChatBskyConvoGetLog, 6 6 ChatBskyConvoSendMessage, 7 - } from '@atproto-labs/api' 7 + } from '@atproto/api' 8 8 import {nanoid} from 'nanoid/non-secure' 9 9 10 10 import {networkRetry} from '#/lib/async/retry' ··· 26 26 } from '#/state/messages/convo/types' 27 27 import {MessagesEventBus} from '#/state/messages/events/agent' 28 28 import {MessagesEventBusError} from '#/state/messages/events/types' 29 + import {DM_SERVICE_HEADERS} from '#/state/queries/messages/const' 29 30 30 31 // TODO temporary 31 32 let DEBUG_ACTIVE_CHAT: string | undefined ··· 46 47 47 48 private agent: BskyAgent 48 49 private events: MessagesEventBus 49 - private __tempFromUserDid: string 50 + private senderUserDid: string 50 51 51 52 private status: ConvoStatus = ConvoStatus.Uninitialized 52 53 private error: ··· 89 90 this.convoId = params.convoId 90 91 this.agent = params.agent 91 92 this.events = params.events 92 - this.__tempFromUserDid = params.__tempFromUserDid 93 + this.senderUserDid = params.agent.session?.did! 93 94 94 95 this.subscribe = this.subscribe.bind(this) 95 96 this.getSnapshot = this.getSnapshot.bind(this) ··· 467 468 { 468 469 convoId: this.convoId, 469 470 }, 470 - { 471 - headers: { 472 - Authorization: this.__tempFromUserDid, 473 - }, 474 - }, 471 + {headers: DM_SERVICE_HEADERS}, 475 472 ) 476 473 }) 477 474 ··· 479 476 480 477 resolve({ 481 478 convo, 482 - sender: convo.members.find(m => m.did === this.__tempFromUserDid), 483 - recipients: convo.members.filter( 484 - m => m.did !== this.__tempFromUserDid, 485 - ), 479 + sender: convo.members.find(m => m.did === this.senderUserDid), 480 + recipients: convo.members.filter(m => m.did !== this.senderUserDid), 486 481 }) 487 482 } catch (e) { 488 483 reject(e) ··· 557 552 convoId: this.convoId, 558 553 limit: isNative ? 30 : 60, 559 554 }, 560 - { 561 - headers: { 562 - Authorization: this.__tempFromUserDid, 563 - }, 564 - }, 555 + {headers: DM_SERVICE_HEADERS}, 565 556 ) 566 557 }) 567 558 const {cursor, messages} = response.data ··· 775 766 convoId: this.convoId, 776 767 message, 777 768 }, 778 - { 779 - encoding: 'application/json', 780 - headers: { 781 - Authorization: this.__tempFromUserDid, 782 - }, 783 - }, 769 + {encoding: 'application/json', headers: DM_SERVICE_HEADERS}, 784 770 ) 785 771 }) 786 772 const res = response.data ··· 792 778 this.newMessages.set(res.id, { 793 779 ...res, 794 780 $type: 'chat.bsky.convo.defs#messageView', 795 - sender: this.sender, 796 781 }) 797 782 this.pendingMessages.delete(id) 798 783 ··· 835 820 message, 836 821 })), 837 822 }, 838 - { 839 - encoding: 'application/json', 840 - headers: { 841 - Authorization: this.__tempFromUserDid, 842 - }, 843 - }, 823 + {encoding: 'application/json', headers: DM_SERVICE_HEADERS}, 844 824 ) 845 825 }) 846 826 const {items} = data ··· 853 833 this.newMessages.set(item.id, { 854 834 ...item, 855 835 $type: 'chat.bsky.convo.defs#messageView', 856 - sender: this.convo?.members.find( 857 - m => m.did === this.__tempFromUserDid, 858 - ), 859 836 }) 860 837 } 861 838 ··· 899 876 convoId: this.convoId, 900 877 messageId, 901 878 }, 902 - { 903 - encoding: 'application/json', 904 - headers: { 905 - Authorization: this.__tempFromUserDid, 906 - }, 907 - }, 879 + {encoding: 'application/json', headers: DM_SERVICE_HEADERS}, 908 880 ) 909 881 }) 910 882 } catch (e: any) { ··· 970 942 id: nanoid(), 971 943 rev: '__fake__', 972 944 sentAt: new Date().toISOString(), 973 - sender: this.sender, 945 + /* 946 + * `getItems` is only run in "active" status states, where 947 + * `this.sender` is defined 948 + */ 949 + sender: this.sender!, 974 950 }, 975 951 nextMessage: null, 976 952 })
+1 -7
src/state/messages/convo/index.tsx
··· 1 1 import React, {useContext, useState, useSyncExternalStore} from 'react' 2 2 import {AppState} from 'react-native' 3 - import {BskyAgent} from '@atproto-labs/api' 4 3 import {useFocusEffect, useIsFocused} from '@react-navigation/native' 5 4 6 5 import {Convo} from '#/state/messages/convo/agent' ··· 8 7 import {useMessagesEventBus} from '#/state/messages/events' 9 8 import {useMarkAsReadMutation} from '#/state/queries/messages/conversation' 10 9 import {useAgent} from '#/state/session' 11 - import {useDmServiceUrlStorage} from '#/screens/Messages/Temp/useDmServiceUrlStorage' 12 10 13 11 const ChatContext = React.createContext<ConvoState | null>(null) 14 12 ··· 25 23 convoId, 26 24 }: Pick<ConvoParams, 'convoId'> & {children: React.ReactNode}) { 27 25 const isScreenFocused = useIsFocused() 28 - const {serviceUrl} = useDmServiceUrlStorage() 29 26 const {getAgent} = useAgent() 30 27 const events = useMessagesEventBus() 31 28 const [convo] = useState( 32 29 () => 33 30 new Convo({ 34 31 convoId, 35 - agent: new BskyAgent({ 36 - service: serviceUrl, 37 - }), 32 + agent: getAgent(), 38 33 events, 39 - __tempFromUserDid: getAgent().session?.did!, 40 34 }), 41 35 ) 42 36 const service = useSyncExternalStore(convo.subscribe, convo.getSnapshot)
+2 -3
src/state/messages/convo/types.ts
··· 1 - import {AppBskyActorDefs} from '@atproto/api' 2 1 import { 2 + AppBskyActorDefs, 3 3 BskyAgent, 4 4 ChatBskyConvoDefs, 5 5 ChatBskyConvoSendMessage, 6 - } from '@atproto-labs/api' 6 + } from '@atproto/api' 7 7 8 8 import {MessagesEventBus} from '#/state/messages/events/agent' 9 9 ··· 11 11 convoId: string 12 12 agent: BskyAgent 13 13 events: MessagesEventBus 14 - __tempFromUserDid: string 15 14 } 16 15 17 16 export enum ConvoStatus {
+4 -13
src/state/messages/events/agent.ts
··· 1 - import {BskyAgent, ChatBskyConvoGetLog} from '@atproto-labs/api' 1 + import {BskyAgent, ChatBskyConvoGetLog} from '@atproto/api' 2 2 import EventEmitter from 'eventemitter3' 3 3 import {nanoid} from 'nanoid/non-secure' 4 4 ··· 13 13 MessagesEventBusParams, 14 14 MessagesEventBusStatus, 15 15 } from '#/state/messages/events/types' 16 + import {DM_SERVICE_HEADERS} from '#/state/queries/messages/const' 16 17 17 18 const LOGGER_CONTEXT = 'MessagesEventBus' 18 19 ··· 20 21 private id: string 21 22 22 23 private agent: BskyAgent 23 - private __tempFromUserDid: string 24 24 private emitter = new EventEmitter<{event: [MessagesEventBusEvent]}>() 25 25 26 26 private status: MessagesEventBusStatus = MessagesEventBusStatus.Initializing ··· 31 31 constructor(params: MessagesEventBusParams) { 32 32 this.id = nanoid(3) 33 33 this.agent = params.agent 34 - this.__tempFromUserDid = params.__tempFromUserDid 35 34 36 35 this.init() 37 36 } ··· 242 241 { 243 242 limit: 1, 244 243 }, 245 - { 246 - headers: { 247 - Authorization: this.__tempFromUserDid, 248 - }, 249 - }, 244 + {headers: DM_SERVICE_HEADERS}, 250 245 ) 251 246 }) 252 247 // throw new Error('UNCOMMENT TO TEST INIT FAILURE') ··· 337 332 { 338 333 cursor: this.latestRev, 339 334 }, 340 - { 341 - headers: { 342 - Authorization: this.__tempFromUserDid, 343 - }, 344 - }, 335 + {headers: DM_SERVICE_HEADERS}, 345 336 ) 346 337 }) 347 338
+2 -9
src/state/messages/events/index.tsx
··· 1 1 import React from 'react' 2 2 import {AppState} from 'react-native' 3 - import {BskyAgent} from '@atproto-labs/api' 4 3 5 4 import {useGate} from '#/lib/statsig/statsig' 6 5 import {isWeb} from '#/platform/detection' 7 6 import {MessagesEventBus} from '#/state/messages/events/agent' 8 7 import {useAgent} from '#/state/session' 9 - import {useDmServiceUrlStorage} from '#/screens/Messages/Temp/useDmServiceUrlStorage' 10 8 import {IS_DEV} from '#/env' 11 9 12 10 const MessagesEventBusContext = React.createContext<MessagesEventBus | null>( ··· 26 24 }: { 27 25 children: React.ReactNode 28 26 }) { 29 - const {serviceUrl} = useDmServiceUrlStorage() 30 27 const {getAgent} = useAgent() 31 28 const [bus] = React.useState( 32 29 () => 33 30 new MessagesEventBus({ 34 - agent: new BskyAgent({ 35 - service: serviceUrl, 36 - }), 37 - __tempFromUserDid: getAgent().session?.did!, 31 + agent: getAgent(), 38 32 }), 39 33 ) 40 34 ··· 74 68 children: React.ReactNode 75 69 }) { 76 70 const gate = useGate() 77 - const {serviceUrl} = useDmServiceUrlStorage() 78 - if (gate('dms') && serviceUrl) { 71 + if (gate('dms')) { 79 72 return ( 80 73 <Temp_MessagesEventBusProvider>{children}</Temp_MessagesEventBusProvider> 81 74 )
+1 -2
src/state/messages/events/types.ts
··· 1 - import {BskyAgent, ChatBskyConvoGetLog} from '@atproto-labs/api' 1 + import {BskyAgent, ChatBskyConvoGetLog} from '@atproto/api' 2 2 3 3 export type MessagesEventBusParams = { 4 4 agent: BskyAgent 5 - __tempFromUserDid: string 6 5 } 7 6 8 7 export enum MessagesEventBusStatus {
+3
src/state/queries/messages/const.ts
··· 1 + export const DM_SERVICE_HEADERS = { 2 + 'atproto-proxy': 'did:web:dms.divy.zone#bsky_chat', 3 + }
+10 -15
src/state/queries/messages/conversation.ts
··· 1 - import {BskyAgent} from '@atproto-labs/api' 2 - import {ConvoView} from '@atproto-labs/api/dist/client/types/chat/bsky/convo/defs' 1 + import {ChatBskyConvoDefs} from '@atproto/api' 3 2 import {useMutation, useQuery, useQueryClient} from '@tanstack/react-query' 4 3 4 + import {DM_SERVICE_HEADERS} from '#/state/queries/messages/const' 5 5 import {useOnMarkAsRead} from '#/state/queries/messages/list-converations' 6 - import {useDmServiceUrlStorage} from '#/screens/Messages/Temp/useDmServiceUrlStorage' 6 + import {useAgent} from '#/state/session' 7 7 import {RQKEY as LIST_CONVOS_KEY} from './list-converations' 8 - import {useHeaders} from './temp-headers' 9 8 10 9 const RQKEY_ROOT = 'convo' 11 10 export const RQKEY = (convoId: string) => [RQKEY_ROOT, convoId] 12 11 13 - export function useConvoQuery(convo: ConvoView) { 14 - const headers = useHeaders() 15 - const {serviceUrl} = useDmServiceUrlStorage() 12 + export function useConvoQuery(convo: ChatBskyConvoDefs.ConvoView) { 13 + const {getAgent} = useAgent() 16 14 17 15 return useQuery({ 18 16 queryKey: RQKEY(convo.id), 19 17 queryFn: async () => { 20 - const agent = new BskyAgent({service: serviceUrl}) 21 - const {data} = await agent.api.chat.bsky.convo.getConvo( 18 + const {data} = await getAgent().api.chat.bsky.convo.getConvo( 22 19 {convoId: convo.id}, 23 - {headers}, 20 + {headers: DM_SERVICE_HEADERS}, 24 21 ) 25 22 return data.convo 26 23 }, ··· 29 26 } 30 27 31 28 export function useMarkAsReadMutation() { 32 - const headers = useHeaders() 33 - const {serviceUrl} = useDmServiceUrlStorage() 34 29 const optimisticUpdate = useOnMarkAsRead() 35 30 const queryClient = useQueryClient() 31 + const {getAgent} = useAgent() 36 32 37 33 return useMutation({ 38 34 mutationFn: async ({ ··· 44 40 }) => { 45 41 if (!convoId) throw new Error('No convoId provided') 46 42 47 - const agent = new BskyAgent({service: serviceUrl}) 48 - await agent.api.chat.bsky.convo.updateRead( 43 + await getAgent().api.chat.bsky.convo.updateRead( 49 44 { 50 45 convoId, 51 46 messageId, 52 47 }, 53 48 { 54 49 encoding: 'application/json', 55 - headers, 50 + headers: DM_SERVICE_HEADERS, 56 51 }, 57 52 ) 58 53 },
+6 -8
src/state/queries/messages/get-convo-for-members.ts
··· 1 - import {BskyAgent, ChatBskyConvoGetConvoForMembers} from '@atproto-labs/api' 1 + import {ChatBskyConvoGetConvoForMembers} from '@atproto/api' 2 2 import {useMutation, useQueryClient} from '@tanstack/react-query' 3 3 4 4 import {logger} from '#/logger' 5 - import {useDmServiceUrlStorage} from '#/screens/Messages/Temp/useDmServiceUrlStorage' 5 + import {DM_SERVICE_HEADERS} from '#/state/queries/messages/const' 6 + import {useAgent} from '#/state/session' 6 7 import {RQKEY as CONVO_KEY} from './conversation' 7 - import {useHeaders} from './temp-headers' 8 8 9 9 export function useGetConvoForMembers({ 10 10 onSuccess, ··· 14 14 onError?: (error: Error) => void 15 15 }) { 16 16 const queryClient = useQueryClient() 17 - const headers = useHeaders() 18 - const {serviceUrl} = useDmServiceUrlStorage() 17 + const {getAgent} = useAgent() 19 18 20 19 return useMutation({ 21 20 mutationFn: async (members: string[]) => { 22 - const agent = new BskyAgent({service: serviceUrl}) 23 - const {data} = await agent.api.chat.bsky.convo.getConvoForMembers( 21 + const {data} = await getAgent().api.chat.bsky.convo.getConvoForMembers( 24 22 {members: members}, 25 - {headers}, 23 + {headers: DM_SERVICE_HEADERS}, 26 24 ) 27 25 28 26 return data
+6 -12
src/state/queries/messages/leave-conversation.ts
··· 1 - import { 2 - BskyAgent, 3 - ChatBskyConvoLeaveConvo, 4 - ChatBskyConvoListConvos, 5 - } from '@atproto-labs/api' 1 + import {ChatBskyConvoLeaveConvo, ChatBskyConvoListConvos} from '@atproto/api' 6 2 import {useMutation, useQueryClient} from '@tanstack/react-query' 7 3 8 4 import {logger} from '#/logger' 9 - import {useDmServiceUrlStorage} from '#/screens/Messages/Temp/useDmServiceUrlStorage' 5 + import {DM_SERVICE_HEADERS} from '#/state/queries/messages/const' 6 + import {useAgent} from '#/state/session' 10 7 import {RQKEY as CONVO_LIST_KEY} from './list-converations' 11 - import {useHeaders} from './temp-headers' 12 8 13 9 export function useLeaveConvo( 14 10 convoId: string | undefined, ··· 21 17 }, 22 18 ) { 23 19 const queryClient = useQueryClient() 24 - const headers = useHeaders() 25 - const {serviceUrl} = useDmServiceUrlStorage() 20 + const {getAgent} = useAgent() 26 21 27 22 return useMutation({ 28 23 mutationFn: async () => { 29 24 if (!convoId) throw new Error('No convoId provided') 30 25 31 - const agent = new BskyAgent({service: serviceUrl}) 32 - const {data} = await agent.api.chat.bsky.convo.leaveConvo( 26 + const {data} = await getAgent().api.chat.bsky.convo.leaveConvo( 33 27 {convoId}, 34 - {headers, encoding: 'application/json'}, 28 + {headers: DM_SERVICE_HEADERS, encoding: 'application/json'}, 35 29 ) 36 30 37 31 return data
+6 -12
src/state/queries/messages/list-converations.ts
··· 1 1 import {useCallback, useMemo} from 'react' 2 - import { 3 - BskyAgent, 4 - ChatBskyConvoDefs, 5 - ChatBskyConvoListConvos, 6 - } from '@atproto-labs/api' 2 + import {ChatBskyConvoDefs, ChatBskyConvoListConvos} from '@atproto/api' 7 3 import {useInfiniteQuery, useQueryClient} from '@tanstack/react-query' 8 4 9 5 import {useCurrentConvoId} from '#/state/messages/current-convo-id' 10 - import {useDmServiceUrlStorage} from '#/screens/Messages/Temp/useDmServiceUrlStorage' 11 - import {useHeaders} from './temp-headers' 6 + import {DM_SERVICE_HEADERS} from '#/state/queries/messages/const' 7 + import {useAgent} from '#/state/session' 12 8 13 9 export const RQKEY = ['convo-list'] 14 10 type RQPageParam = string | undefined 15 11 16 12 export function useListConvos({refetchInterval}: {refetchInterval: number}) { 17 - const headers = useHeaders() 18 - const {serviceUrl} = useDmServiceUrlStorage() 13 + const {getAgent} = useAgent() 19 14 20 15 return useInfiniteQuery({ 21 16 queryKey: RQKEY, 22 17 queryFn: async ({pageParam}) => { 23 - const agent = new BskyAgent({service: serviceUrl}) 24 - const {data} = await agent.api.chat.bsky.convo.listConvos( 18 + const {data} = await getAgent().api.chat.bsky.convo.listConvos( 25 19 {cursor: pageParam}, 26 - {headers}, 20 + {headers: DM_SERVICE_HEADERS}, 27 21 ) 28 22 29 23 return data
+7 -9
src/state/queries/messages/mute-conversation.ts
··· 1 1 import { 2 - BskyAgent, 3 2 ChatBskyConvoDefs, 4 3 ChatBskyConvoListConvos, 5 4 ChatBskyConvoMuteConvo, 6 - } from '@atproto-labs/api' 5 + } from '@atproto/api' 7 6 import {InfiniteData, useMutation, useQueryClient} from '@tanstack/react-query' 8 7 9 - import {useDmServiceUrlStorage} from '#/screens/Messages/Temp/useDmServiceUrlStorage' 8 + import {DM_SERVICE_HEADERS} from '#/state/queries/messages/const' 9 + import {useAgent} from '#/state/session' 10 10 import {RQKEY as CONVO_KEY} from './conversation' 11 11 import {RQKEY as CONVO_LIST_KEY} from './list-converations' 12 - import {useHeaders} from './temp-headers' 13 12 14 13 export function useMuteConvo( 15 14 convoId: string | undefined, ··· 22 21 }, 23 22 ) { 24 23 const queryClient = useQueryClient() 25 - const headers = useHeaders() 26 - const {serviceUrl} = useDmServiceUrlStorage() 24 + const {getAgent} = useAgent() 27 25 28 26 return useMutation({ 29 27 mutationFn: async ({mute}: {mute: boolean}) => { 30 28 if (!convoId) throw new Error('No convoId provided') 31 29 32 - const agent = new BskyAgent({service: serviceUrl}) 30 + const agent = getAgent() 33 31 if (mute) { 34 32 const {data} = await agent.api.chat.bsky.convo.muteConvo( 35 33 {convoId}, 36 - {headers, encoding: 'application/json'}, 34 + {headers: DM_SERVICE_HEADERS, encoding: 'application/json'}, 37 35 ) 38 36 return data 39 37 } else { 40 38 const {data} = await agent.api.chat.bsky.convo.unmuteConvo( 41 39 {convoId}, 42 - {headers, encoding: 'application/json'}, 40 + {headers: DM_SERVICE_HEADERS, encoding: 'application/json'}, 43 41 ) 44 42 return data 45 43 }
-11
src/state/queries/messages/temp-headers.ts
··· 1 - import {useSession} from '#/state/session' 2 - 3 - // toy auth 4 - export const useHeaders = () => { 5 - const {currentAccount} = useSession() 6 - return { 7 - get Authorization() { 8 - return currentAccount!.did 9 - }, 10 - } 11 - }
+4 -16
yarn.lock
··· 34 34 jsonpointer "^5.0.0" 35 35 leven "^3.1.0" 36 36 37 - "@atproto-labs/api@^0.12.8-clipclops.0": 38 - version "0.12.8-clipclops.0" 39 - resolved "https://registry.yarnpkg.com/@atproto-labs/api/-/api-0.12.8-clipclops.0.tgz#1c5d41d3396e439a0b645f7e1ccf500cc4b42580" 40 - integrity sha512-YYDtWWk6BR+aRBVja/1v+gceNK81lkmF5bi6O4pTmJhFt/321XATx/ql8uTWta4VnVThoFeNPG6nLr7hs8b9cA== 37 + "@atproto/api@^0.12.10": 38 + version "0.12.10" 39 + resolved "https://registry.yarnpkg.com/@atproto/api/-/api-0.12.10.tgz#a745f0e9a273a8e42d208e6d7f91535b73619720" 40 + integrity sha512-WhZXvtVENdWSqfiPKiVIjX84r1zFnpEKApyh8rBjxBzGstWfabiz7bKW2eybZNHMty1IyFHwMHaLXPruoSJlHQ== 41 41 dependencies: 42 42 "@atproto/common-web" "^0.3.0" 43 43 "@atproto/lexicon" "^0.4.0" ··· 50 50 version "0.12.3" 51 51 resolved "https://registry.yarnpkg.com/@atproto/api/-/api-0.12.3.tgz#5b7b1c7d4210ee9315961504900c8409395cbb17" 52 52 integrity sha512-y/kGpIEo+mKGQ7VOphpqCAigTI0LZRmDThNChTfSzDKm9TzEobwiw0zUID0Yw6ot1iLLFx3nKURmuZAYlEuobw== 53 - dependencies: 54 - "@atproto/common-web" "^0.3.0" 55 - "@atproto/lexicon" "^0.4.0" 56 - "@atproto/syntax" "^0.3.0" 57 - "@atproto/xrpc" "^0.5.0" 58 - multiformats "^9.9.0" 59 - tlds "^1.234.0" 60 - 61 - "@atproto/api@^0.12.9": 62 - version "0.12.9" 63 - resolved "https://registry.yarnpkg.com/@atproto/api/-/api-0.12.9.tgz#5ae040980e574a5d9496368c4ca032c0cda174ec" 64 - integrity sha512-3D4n2ZAAsDRnjevvcoIxQxuMMoqc+7vtVyP7EnrEdeOmRSCF9j8yXTqhn6rcHCbzcs3DKyYR26nQemtZsMsE0g== 65 53 dependencies: 66 54 "@atproto/common-web" "^0.3.0" 67 55 "@atproto/lexicon" "^0.4.0"