Skip to content

Commit

Permalink
chat: Make tdlib delete messages from our own cache
Browse files Browse the repository at this point in the history
We finally handle chat opening/closing and we also track visible
messages, so this should be enough for a complete correct message cache
management.
  • Loading branch information
melix99 committed Feb 23, 2023
1 parent eec531e commit df27891
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions src/tdlib/chat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,20 +264,16 @@ impl Chat {
self.set_unread_mention_count(update.unread_mention_count)
}
DeleteMessages(data) => {
// FIXME: This should be removed after we notify opened and closed chats to TDLib
// See discussion here: https://t.me/tdlibchat/65304
if !data.from_cache {
let mut messages = imp.messages.borrow_mut();
let deleted_messages: Vec<Message> = data
.message_ids
.into_iter()
.filter_map(|id| messages.remove(&id))
.collect();

drop(messages);
for message in deleted_messages {
self.emit_by_name::<()>("deleted-message", &[&message]);
}
let mut messages = imp.messages.borrow_mut();
let deleted_messages: Vec<Message> = data
.message_ids
.into_iter()
.filter_map(|id| messages.remove(&id))
.collect();

drop(messages);
for message in deleted_messages {
self.emit_by_name::<()>("deleted-message", &[&message]);
}
}
MessageContent(ref data) => {
Expand Down

0 comments on commit df27891

Please sign in to comment.