I try to send multiple message via telegram. After a while I got a flooded-error. Than I set my program to sleep and go ahead after the timeout value.
That works good, but sometimes tdlib call a updateDeleteMessages and I dont't know how to avoid or handle this. Why does tdlib delete those messages?
TDLib unloads unneeded messages from the memory. You receive updateDeleteMessages with from_cache == true if that happens. In your case failed to send and successfully sent messages are likely to be unloaded.
I set the tdlibParameters fields in this way.
use_file_database: true,
use_chat_info_database: true,
use_message_database: true,
use_secret_chats: false,
enable_storage_optimizer: false
But after a period of time, messages are cleared and an updateDeleteMessages event is sent with the value of from_cache == true. I tried to get 20 the last message with getChatHistory, but quickly called an updateDeleteMessages event and erases messages.
@David-MKoch Messages are constantly unloaded from the memory cache to ensure small memory footprint. updateDeleteMessages with from_cache == true is sent whenever this happens, so the client can delete them from its cache if there is any. You can safely ignore updateDeleteMessages with from_cache == true if you don't have message cache.
So a message model does not count as a cache, right? The model will request more messages again when scrolling back, so this should not be an issue?
@Flohack74 TDLib doesn't unload messages in a currently opened chat, so messages currently shown to the user shouldn't be unloaded from the memory. It doesn't harm to always ignore updates with from_cache == true.
@Flohack74 TDLib doesn't unload messages in a currently opened chat, so messages currently shown to the user shouldn't be unloaded from the memory. It doesn't harm to always ignore updates with
from_cache == true.
But it can delete some media files used in opened chats without any update notification from TDLib?
@zevlg TDLib can't delete files from cache without an update. Application will receive updateFile after the file is deleted.
Most helpful comment
@David-MKoch Messages are constantly unloaded from the memory cache to ensure small memory footprint.
updateDeleteMessageswithfrom_cache == trueis sent whenever this happens, so the client can delete them from its cache if there is any. You can safely ignoreupdateDeleteMessageswithfrom_cache == trueif you don't have message cache.