[🐴] 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:
@@ -1,4 +1,4 @@
|
||||
import {BskyAgent, ChatBskyConvoGetLog} from '@atproto-labs/api'
|
||||
import {BskyAgent, ChatBskyConvoGetLog} from '@atproto/api'
|
||||
import EventEmitter from 'eventemitter3'
|
||||
import {nanoid} from 'nanoid/non-secure'
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
MessagesEventBusParams,
|
||||
MessagesEventBusStatus,
|
||||
} from '#/state/messages/events/types'
|
||||
import {DM_SERVICE_HEADERS} from '#/state/queries/messages/const'
|
||||
|
||||
const LOGGER_CONTEXT = 'MessagesEventBus'
|
||||
|
||||
@@ -20,7 +21,6 @@ export class MessagesEventBus {
|
||||
private id: string
|
||||
|
||||
private agent: BskyAgent
|
||||
private __tempFromUserDid: string
|
||||
private emitter = new EventEmitter<{event: [MessagesEventBusEvent]}>()
|
||||
|
||||
private status: MessagesEventBusStatus = MessagesEventBusStatus.Initializing
|
||||
@@ -31,7 +31,6 @@ export class MessagesEventBus {
|
||||
constructor(params: MessagesEventBusParams) {
|
||||
this.id = nanoid(3)
|
||||
this.agent = params.agent
|
||||
this.__tempFromUserDid = params.__tempFromUserDid
|
||||
|
||||
this.init()
|
||||
}
|
||||
@@ -242,11 +241,7 @@ export class MessagesEventBus {
|
||||
{
|
||||
limit: 1,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: this.__tempFromUserDid,
|
||||
},
|
||||
},
|
||||
{headers: DM_SERVICE_HEADERS},
|
||||
)
|
||||
})
|
||||
// throw new Error('UNCOMMENT TO TEST INIT FAILURE')
|
||||
@@ -337,11 +332,7 @@ export class MessagesEventBus {
|
||||
{
|
||||
cursor: this.latestRev,
|
||||
},
|
||||
{
|
||||
headers: {
|
||||
Authorization: this.__tempFromUserDid,
|
||||
},
|
||||
},
|
||||
{headers: DM_SERVICE_HEADERS},
|
||||
)
|
||||
})
|
||||
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import React from 'react'
|
||||
import {AppState} from 'react-native'
|
||||
import {BskyAgent} from '@atproto-labs/api'
|
||||
|
||||
import {useGate} from '#/lib/statsig/statsig'
|
||||
import {isWeb} from '#/platform/detection'
|
||||
import {MessagesEventBus} from '#/state/messages/events/agent'
|
||||
import {useAgent} from '#/state/session'
|
||||
import {useDmServiceUrlStorage} from '#/screens/Messages/Temp/useDmServiceUrlStorage'
|
||||
import {IS_DEV} from '#/env'
|
||||
|
||||
const MessagesEventBusContext = React.createContext<MessagesEventBus | null>(
|
||||
@@ -26,15 +24,11 @@ export function Temp_MessagesEventBusProvider({
|
||||
}: {
|
||||
children: React.ReactNode
|
||||
}) {
|
||||
const {serviceUrl} = useDmServiceUrlStorage()
|
||||
const {getAgent} = useAgent()
|
||||
const [bus] = React.useState(
|
||||
() =>
|
||||
new MessagesEventBus({
|
||||
agent: new BskyAgent({
|
||||
service: serviceUrl,
|
||||
}),
|
||||
__tempFromUserDid: getAgent().session?.did!,
|
||||
agent: getAgent(),
|
||||
}),
|
||||
)
|
||||
|
||||
@@ -74,8 +68,7 @@ export function MessagesEventBusProvider({
|
||||
children: React.ReactNode
|
||||
}) {
|
||||
const gate = useGate()
|
||||
const {serviceUrl} = useDmServiceUrlStorage()
|
||||
if (gate('dms') && serviceUrl) {
|
||||
if (gate('dms')) {
|
||||
return (
|
||||
<Temp_MessagesEventBusProvider>{children}</Temp_MessagesEventBusProvider>
|
||||
)
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import {BskyAgent, ChatBskyConvoGetLog} from '@atproto-labs/api'
|
||||
import {BskyAgent, ChatBskyConvoGetLog} from '@atproto/api'
|
||||
|
||||
export type MessagesEventBusParams = {
|
||||
agent: BskyAgent
|
||||
__tempFromUserDid: string
|
||||
}
|
||||
|
||||
export enum MessagesEventBusStatus {
|
||||
|
||||
Reference in New Issue
Block a user