eilvelia / tdl

Node.js bindings to TDLib 🥒
MIT License
423 stars 52 forks source link

Add the ability to ignore updates from the client #57

Closed David-MKoch closed 5 years ago

David-MKoch commented 5 years ago

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 want to ignore the updateDeleteMessages with the value of from_cache == true by the client.

eilvelia commented 5 years ago

Well, currently tdl just emits all received updates. It is assumed that the user will filter all unneeded updates themselves.

For example, using RxJS:

const updates$ = Rx.fromEvent(client, 'update')
  .filter(u => u._ === 'updateDeleteMessages' ? !u.from_cache : true)