fix chat duplicates when small number of messages

This commit is contained in:
Alexander Zveruk 2020-05-03 16:39:51 +03:00
parent 59dfcd5bbf
commit 23ab03bd65

View file

@ -97,10 +97,15 @@ class ChatModel:
# return data from cache
return self.chats[offset:limit]
previous_chats_num = len(self.chat_ids)
self.get_chat_ids(
offset=len(self.chats),
limit=len(self.chats) + limit
)
if len(self.chat_ids) == previous_chats_num:
return self.chats[offset:limit]
for chat_id in self.chat_ids:
chat = self.get_chat(chat_id)
self.chats.append(chat)