Forwards: Fix error after forwarding (#3224)
This commit is contained in:
parent
62271f6ced
commit
c70fe8e42d
@ -141,7 +141,7 @@ export function buildApiMessageFromNotification(
|
|||||||
notification: GramJs.UpdateServiceNotification,
|
notification: GramJs.UpdateServiceNotification,
|
||||||
currentDate: number,
|
currentDate: number,
|
||||||
): ApiMessage {
|
): ApiMessage {
|
||||||
const localId = getNextLocalMessageId();
|
const localId = getNextLocalMessageId(currentDate);
|
||||||
const content = buildMessageContent(notification);
|
const content = buildMessageContent(notification);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@ -1359,7 +1359,7 @@ export function buildLocalForwardedMessage({
|
|||||||
noCaptions?: boolean;
|
noCaptions?: boolean;
|
||||||
isCurrentUserPremium?: boolean;
|
isCurrentUserPremium?: boolean;
|
||||||
}): ApiMessage {
|
}): ApiMessage {
|
||||||
const localId = getNextLocalMessageId();
|
const localId = getNextLocalMessageId(toChat?.lastMessage?.id);
|
||||||
const {
|
const {
|
||||||
content,
|
content,
|
||||||
chatId: fromChatId,
|
chatId: fromChatId,
|
||||||
|
|||||||
@ -215,6 +215,7 @@ export async function fetchMessage({ chat, messageId }: { chat: ApiChat; message
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mediaQueue = Promise.resolve();
|
let mediaQueue = Promise.resolve();
|
||||||
|
let lastSendMessagePromise = Promise.resolve();
|
||||||
|
|
||||||
export function sendMessage(
|
export function sendMessage(
|
||||||
{
|
{
|
||||||
@ -307,7 +308,7 @@ export function sendMessage(
|
|||||||
}, randomId, localMessage, onProgress);
|
}, randomId, localMessage, onProgress);
|
||||||
}
|
}
|
||||||
|
|
||||||
const sendPromise = (async () => {
|
lastSendMessagePromise = (async () => {
|
||||||
let media: GramJs.TypeInputMedia | undefined;
|
let media: GramJs.TypeInputMedia | undefined;
|
||||||
if (attachment) {
|
if (attachment) {
|
||||||
try {
|
try {
|
||||||
@ -367,7 +368,7 @@ export function sendMessage(
|
|||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
return sendPromise;
|
return lastSendMessagePromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
const groupedUploads: Record<string, {
|
const groupedUploads: Record<string, {
|
||||||
@ -480,6 +481,8 @@ function sendGroupedMedia(
|
|||||||
if (update) handleMultipleLocalMessagesUpdate(localMessages, update);
|
if (update) handleMultipleLocalMessagesUpdate(localMessages, update);
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
lastSendMessagePromise = mediaQueue;
|
||||||
|
|
||||||
return mediaQueue;
|
return mediaQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1292,6 +1295,8 @@ export async function forwardMessages({
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
await lastSendMessagePromise;
|
||||||
|
|
||||||
const update = await invokeRequest(new GramJs.messages.ForwardMessages({
|
const update = await invokeRequest(new GramJs.messages.ForwardMessages({
|
||||||
fromPeer: buildInputPeer(fromChat.id, fromChat.accessHash),
|
fromPeer: buildInputPeer(fromChat.id, fromChat.accessHash),
|
||||||
toPeer: buildInputPeer(toChat.id, toChat.accessHash),
|
toPeer: buildInputPeer(toChat.id, toChat.accessHash),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user