Skip to content

Refactor chats model: Make it accessible from everywhere, make forward info origin a factory pattern

Flo Lee requested to merge forwardinfo-factory into master

Currently the chats model is instantiated by QML and as such not really accessible everywhere. That leads to code calling into tdlib to load chats temporarily since the model cannot be queried. Thats imperformant and risks race conditions and outdated data. This MR refactors the chats model into a global instance() variable, which can be called from everywhere. Chats and SortedChats classes are introduced to be safely instantiated by QML still, where needed. The whole idea was taken from Users model, where this pattern already existed. As a side-effect we also try to fix ForwardInfoOrigin usage, embedding it into a factory pattern and reusing already the idea of the global chats model access. That should prevent ugly crashes with forward info in some cases.

Edited by Flo Lee

Merge request reports