tdlib / td

Cross-platform library for building Telegram clients
https://core.telegram.org/tdlib
Boost Software License 1.0
7.11k stars 1.44k forks source link

How to properly load all the chats? #2423

Closed xephosbot closed 1 year ago

xephosbot commented 1 year ago

Following the Java example, I recursively call the LoadChats method until I get a 404 error. However, I get this error even when less than half of the chats are loaded.

levlam commented 1 year ago

See https://core.telegram.org/tdlib/getting-started#getting-the-lists-of-chats. Basically, you need to listen to updates and change chat order based on the updates. If you receive 404 from loadChats, then all relevant updates has already been sent.

xephosbot commented 1 year ago

And how do I control the order of updates? For example, if the chat update event came with chatId before I got it from newChatUpdate.

levlam commented 1 year ago

See https://core.telegram.org/tdlib/getting-started#handling-updates.

xephosbot commented 1 year ago

And so, if I need to load messages from all ChatList then I need to call multiple times loadChats with the required chatList? Until I call loadChats from ChatListArchive or ChatListFolder, the chat updates won't come from there?

levlam commented 1 year ago

The updates for a chat list can be received if loading of the chat list is required to answer some other request besides loadChats.