[Chat] Add embeds to the optimistic message (#10564)
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import {
|
||||
type $Typed,
|
||||
type AppBskyEmbedRecord,
|
||||
type AtpAgent,
|
||||
type ChatBskyActorDefs,
|
||||
ChatBskyConvoDefs,
|
||||
@@ -104,7 +106,11 @@ export class Convo {
|
||||
> = new Map()
|
||||
private pendingMessages: Map<
|
||||
string,
|
||||
{id: string; message: ChatBskyConvoSendMessage.InputSchema['message']}
|
||||
{
|
||||
id: string
|
||||
message: ChatBskyConvoSendMessage.InputSchema['message']
|
||||
optimisticEmbedView?: $Typed<AppBskyEmbedRecord.View>
|
||||
}
|
||||
> = new Map()
|
||||
private deletedMessages: Set<string> = new Set()
|
||||
private relatedProfiles: Map<string, ChatBskyActorDefs.ProfileViewBasic> =
|
||||
@@ -934,7 +940,10 @@ export class Convo {
|
||||
|
||||
private pendingMessageFailure: 'recoverable' | 'unrecoverable' | null = null
|
||||
|
||||
sendMessage(message: ChatBskyConvoSendMessage.InputSchema['message']) {
|
||||
sendMessage(
|
||||
message: ChatBskyConvoSendMessage.InputSchema['message'],
|
||||
optimisticEmbedView?: $Typed<AppBskyEmbedRecord.View>,
|
||||
) {
|
||||
// Ignore empty messages for now since they have no other purpose atm
|
||||
if (!message.text.trim() && !message.embed) return
|
||||
|
||||
@@ -946,6 +955,7 @@ export class Convo {
|
||||
this.pendingMessages.set(tempId, {
|
||||
id: tempId,
|
||||
message,
|
||||
optimisticEmbedView,
|
||||
})
|
||||
if (this.convo?.view.status === 'request') {
|
||||
this.updateConvo({
|
||||
@@ -1292,7 +1302,7 @@ export class Convo {
|
||||
key: m.id,
|
||||
message: {
|
||||
...m.message,
|
||||
embed: undefined,
|
||||
embed: m.optimisticEmbedView,
|
||||
$type: 'chat.bsky.convo.defs#messageView',
|
||||
id: nanoid(),
|
||||
rev: '__fake__',
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import {
|
||||
type $Typed,
|
||||
type AppBskyEmbedRecord,
|
||||
type BskyAgent,
|
||||
type ChatBskyActorDefs,
|
||||
type ChatBskyConvoDefs,
|
||||
@@ -106,6 +108,7 @@ export type ConvoItem =
|
||||
type DeleteMessage = (messageId: string) => Promise<void>
|
||||
type SendMessage = (
|
||||
message: ChatBskyConvoSendMessage.InputSchema['message'],
|
||||
optimisticEmbedView: $Typed<AppBskyEmbedRecord.View> | undefined,
|
||||
) => void
|
||||
type FetchMessageHistory = () => Promise<void>
|
||||
type MarkConvoAccepted = () => void
|
||||
|
||||
Reference in New Issue
Block a user