This reverts commit d424945eed
.
zio/stable
parent
1ff15b47f4
commit
0444e69c35
|
@ -766,12 +766,12 @@ export class Convo {
|
||||||
logger.DebugContext.convo,
|
logger.DebugContext.convo,
|
||||||
)
|
)
|
||||||
|
|
||||||
const pendingMessages = Array.from(this.pendingMessages.values())
|
const pendingMessage = Array.from(this.pendingMessages.values()).shift()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If there are no pending messages, we're done.
|
* If there are no pending messages, we're done.
|
||||||
*/
|
*/
|
||||||
if (pendingMessages.length === 0) {
|
if (!pendingMessage) {
|
||||||
this.isProcessingPendingMessages = false
|
this.isProcessingPendingMessages = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -779,34 +779,28 @@ export class Convo {
|
||||||
try {
|
try {
|
||||||
this.isProcessingPendingMessages = true
|
this.isProcessingPendingMessages = true
|
||||||
|
|
||||||
|
const {id, message} = pendingMessage
|
||||||
|
|
||||||
const response = await networkRetry(2, () => {
|
const response = await networkRetry(2, () => {
|
||||||
return this.agent.api.chat.bsky.convo.sendMessageBatch(
|
return this.agent.api.chat.bsky.convo.sendMessage(
|
||||||
{
|
{
|
||||||
items: pendingMessages.map(({message}) => ({
|
convoId: this.convoId,
|
||||||
convoId: this.convoId,
|
message,
|
||||||
message,
|
|
||||||
})),
|
|
||||||
},
|
},
|
||||||
{encoding: 'application/json', headers: DM_SERVICE_HEADERS},
|
{encoding: 'application/json', headers: DM_SERVICE_HEADERS},
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
const res = response.data
|
||||||
|
|
||||||
const {items} = response.data
|
/*
|
||||||
|
* Insert into `newMessages` as soon as we have a real ID. That way, when
|
||||||
for (let i = 0; i < items.length; i++) {
|
* we get an event log back, we can replace in situ.
|
||||||
const msg = items[i]
|
*/
|
||||||
const tempId = pendingMessages[i].id
|
this.newMessages.set(res.id, {
|
||||||
|
...res,
|
||||||
/*
|
$type: 'chat.bsky.convo.defs#messageView',
|
||||||
* Insert into `newMessages` as soon as we have a real ID. That way, when
|
})
|
||||||
* we get an event log back, we can replace in situ.
|
this.pendingMessages.delete(id)
|
||||||
*/
|
|
||||||
this.newMessages.set(msg.id, {
|
|
||||||
...msg,
|
|
||||||
$type: 'chat.bsky.convo.defs#messageView',
|
|
||||||
})
|
|
||||||
this.pendingMessages.delete(tempId)
|
|
||||||
}
|
|
||||||
|
|
||||||
await this.processPendingMessages()
|
await this.processPendingMessages()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue