Forwards: Fix error after forwarding (#3224)

This commit is contained in:
Alexander Zinchuk 2023-05-28 14:32:44 +02:00
parent 62271f6ced
commit c70fe8e42d
2 changed files with 9 additions and 4 deletions

View File

@ -141,7 +141,7 @@ export function buildApiMessageFromNotification(
notification: GramJs.UpdateServiceNotification,
currentDate: number,
): ApiMessage {
const localId = getNextLocalMessageId();
const localId = getNextLocalMessageId(currentDate);
const content = buildMessageContent(notification);
return {
@ -1359,7 +1359,7 @@ export function buildLocalForwardedMessage({
noCaptions?: boolean;
isCurrentUserPremium?: boolean;
}): ApiMessage {
const localId = getNextLocalMessageId();
const localId = getNextLocalMessageId(toChat?.lastMessage?.id);
const {
content,
chatId: fromChatId,

View File

@ -215,6 +215,7 @@ export async function fetchMessage({ chat, messageId }: { chat: ApiChat; message
}
let mediaQueue = Promise.resolve();
let lastSendMessagePromise = Promise.resolve();
export function sendMessage(
{
@ -307,7 +308,7 @@ export function sendMessage(
}, randomId, localMessage, onProgress);
}
const sendPromise = (async () => {
lastSendMessagePromise = (async () => {
let media: GramJs.TypeInputMedia | undefined;
if (attachment) {
try {
@ -367,7 +368,7 @@ export function sendMessage(
}
})();
return sendPromise;
return lastSendMessagePromise;
}
const groupedUploads: Record<string, {
@ -480,6 +481,8 @@ function sendGroupedMedia(
if (update) handleMultipleLocalMessagesUpdate(localMessages, update);
})();
lastSendMessagePromise = mediaQueue;
return mediaQueue;
}
@ -1292,6 +1295,8 @@ export async function forwardMessages({
});
});
await lastSendMessagePromise;
const update = await invokeRequest(new GramJs.messages.ForwardMessages({
fromPeer: buildInputPeer(fromChat.id, fromChat.accessHash),
toPeer: buildInputPeer(toChat.id, toChat.accessHash),