fix(client): sendMediaGroup returns all sent messages
This commit is contained in:
parent
e6e28399b0
commit
9bee00e584
2 changed files with 26 additions and 4 deletions
|
@ -989,7 +989,6 @@ export interface TelegramClient extends BaseTelegramClient {
|
|||
*
|
||||
* @param latitude Latitude of the location
|
||||
* @param longitude Longitude of the location
|
||||
|
||||
*/
|
||||
getNearbyChats(latitude: number, longitude: number): Promise<Chat[]>
|
||||
/**
|
||||
|
@ -2295,7 +2294,7 @@ export interface TelegramClient extends BaseTelegramClient {
|
|||
*/
|
||||
clearDraft?: boolean
|
||||
}
|
||||
): Promise<Message>
|
||||
): Promise<Message[]>
|
||||
/**
|
||||
* Send a single media (a photo or a document-based media)
|
||||
*
|
||||
|
|
|
@ -8,6 +8,8 @@ import {
|
|||
} from '../../types'
|
||||
import { normalizeDate, randomUlong } from '../../utils/misc-utils'
|
||||
import { tl } from '@mtcute/tl'
|
||||
import { assertIsUpdatesGroup } from '../../utils/updates-utils'
|
||||
import { createUsersChatsIndex } from '../../utils/peer-utils'
|
||||
|
||||
/**
|
||||
* Send a group of media.
|
||||
|
@ -75,7 +77,7 @@ export async function sendMediaGroup(
|
|||
*/
|
||||
clearDraft?: boolean
|
||||
}
|
||||
): Promise<Message> {
|
||||
): Promise<Message[]> {
|
||||
if (!params) params = {}
|
||||
|
||||
const peer = await this.resolvePeer(chatId)
|
||||
|
@ -123,5 +125,26 @@ export async function sendMediaGroup(
|
|||
clearDraft: params.clearDraft,
|
||||
})
|
||||
|
||||
return this._findMessageInUpdate(res)
|
||||
assertIsUpdatesGroup('_findMessageInUpdate', res)
|
||||
this._handleUpdate(res, true)
|
||||
|
||||
const { users, chats } = createUsersChatsIndex(res)
|
||||
|
||||
return res.updates
|
||||
.filter(
|
||||
(u) =>
|
||||
u._ === 'updateNewMessage' ||
|
||||
u._ === 'updateNewChannelMessage' ||
|
||||
u._ === 'updateNewScheduledMessage'
|
||||
)
|
||||
.map(
|
||||
(u) =>
|
||||
new Message(
|
||||
this,
|
||||
(u as any).message,
|
||||
users,
|
||||
chats,
|
||||
u._ === 'updateNewScheduledMessage'
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue