From 23ab03bd654546472229ae67ea720756ba292f79 Mon Sep 17 00:00:00 2001 From: Alexander Zveruk Date: Sun, 3 May 2020 16:39:51 +0300 Subject: [PATCH] fix chat duplicates when small number of messages --- tg/models/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tg/models/__init__.py b/tg/models/__init__.py index 371e989..5578586 100644 --- a/tg/models/__init__.py +++ b/tg/models/__init__.py @@ -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)