Fix replying in discussions (#1954)

This commit is contained in:
Alexander Zinchuk 2022-07-20 16:02:06 +02:00
parent 9b3050d179
commit 5581b2b421
3 changed files with 10 additions and 0 deletions

View File

@ -1147,6 +1147,7 @@ export function buildLocalMessage(
text?: string,
entities?: ApiMessageEntity[],
replyingTo?: number,
replyingToTopId?: number,
attachment?: ApiAttachment,
sticker?: ApiSticker,
gif?: ApiVideo,
@ -1181,6 +1182,7 @@ export function buildLocalMessage(
isOutgoing: !isChannel,
senderId: sendAs?.id || currentUserId,
...(replyingTo && { replyToMessageId: replyingTo }),
...(replyingToTopId && { replyToTopMessageId: replyingToTopId }),
...(groupedId && {
groupedId,
...(media && (media.photo || media.video) && { isInAlbum: true }),

View File

@ -202,6 +202,7 @@ export function sendMessage(
text,
entities,
replyingTo,
replyingToTopId,
attachment,
sticker,
gif,
@ -218,6 +219,7 @@ export function sendMessage(
text?: string;
entities?: ApiMessageEntity[];
replyingTo?: number;
replyingToTopId?: number;
attachment?: ApiAttachment;
sticker?: ApiSticker;
gif?: ApiVideo;
@ -237,6 +239,7 @@ export function sendMessage(
text,
entities,
replyingTo,
replyingToTopId,
attachment,
sticker,
gif,

View File

@ -912,6 +912,7 @@ async function sendMessage(params: {
isSilent?: boolean;
scheduledAt?: number;
sendAs?: ApiChat | ApiUser;
replyingToTopId?: number;
}) {
let localId: number | undefined;
const progressCallback = params.attachment ? (progress: number, messageLocalId: number) => {
@ -950,6 +951,10 @@ async function sendMessage(params: {
params.replyingTo = selectThreadTopMessageId(global, params.chat.id, threadId)!;
}
if (params.replyingTo && !params.replyingToTopId && threadId !== MAIN_THREAD_ID) {
params.replyingToTopId = selectThreadTopMessageId(global, params.chat.id, threadId)!;
}
await callApi('sendMessage', params, progressCallback);
if (progressCallback && localId) {