mirror of
https://github.com/xCyanGrizzly/DragonsStash.git
synced 2026-05-11 06:11:15 +00:00
fix: add getChat and sync delay after openChat for proper history loading
This commit is contained in:
@@ -154,12 +154,27 @@ export async function getChannelMessages(
|
|||||||
const photos: TelegramPhoto[] = [];
|
const photos: TelegramPhoto[] = [];
|
||||||
const boundary = lastProcessedMessageId ? Number(lastProcessedMessageId) : null;
|
const boundary = lastProcessedMessageId ? Number(lastProcessedMessageId) : null;
|
||||||
|
|
||||||
// Open the chat so TDLib loads remote messages
|
// Open the chat so TDLib loads remote messages, then load chat history
|
||||||
|
// from the server. getChat forces TDLib to fetch chat metadata and
|
||||||
|
// getChatHistory with from_message_id=0 triggers a server-side fetch.
|
||||||
await invokeWithTimeout(client, {
|
await invokeWithTimeout(client, {
|
||||||
_: "openChat",
|
_: "openChat",
|
||||||
chat_id: Number(chatId),
|
chat_id: Number(chatId),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Force TDLib to load the full chat list which populates chat state
|
||||||
|
try {
|
||||||
|
await invokeWithTimeout(client, {
|
||||||
|
_: "getChat",
|
||||||
|
chat_id: Number(chatId),
|
||||||
|
});
|
||||||
|
} catch {
|
||||||
|
// Ignore - chat may already be loaded
|
||||||
|
}
|
||||||
|
|
||||||
|
// Give TDLib time to sync chat data from the server
|
||||||
|
await sleep(2000);
|
||||||
|
|
||||||
let currentFromId = 0;
|
let currentFromId = 0;
|
||||||
let totalScanned = 0;
|
let totalScanned = 0;
|
||||||
let pageCount = 0;
|
let pageCount = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user