mirror of
https://github.com/paul-nameless/tg
synced 2024-11-25 13:20:25 +00:00
improve naming
This commit is contained in:
parent
763cbc15da
commit
426f3a0fa2
2 changed files with 13 additions and 14 deletions
|
@ -136,8 +136,8 @@ class Controller:
|
|||
|
||||
def refresh_msgs(self):
|
||||
self.view.msgs.users = self.model.users
|
||||
msgs = self.model.get_current_msgs(limit=self.view.msgs.h)
|
||||
self.view.draw_msgs(self.model.get_current_msg(), msgs)
|
||||
msgs = self.model.fetch_msgs(limit=self.view.msgs.h)
|
||||
self.view.draw_msgs(self.model.get_current_msgs(), msgs)
|
||||
|
||||
def update_handler(self, update):
|
||||
try:
|
||||
|
|
|
@ -23,11 +23,19 @@ class Model:
|
|||
return None
|
||||
return self.chats.chat_ids[self.current_chat]
|
||||
|
||||
def get_current_msg(self):
|
||||
def get_current_msgs(self):
|
||||
chat_id = self.get_current_chat_id()
|
||||
if chat_id is None:
|
||||
return []
|
||||
return self.msgs.current_msgs[self.get_current_chat_id()]
|
||||
return self.msgs.current_msgs[chat_id]
|
||||
|
||||
def fetch_msgs(self, offset=0, limit=10):
|
||||
chat_id = self.get_current_chat_id()
|
||||
if chat_id is None:
|
||||
return []
|
||||
return self.msgs.fetch_msgs(
|
||||
chat_id, offset=offset, limit=limit
|
||||
)
|
||||
|
||||
def jump_bottom(self):
|
||||
chat_id = self.chats.chat_ids[self.current_chat]
|
||||
|
@ -71,15 +79,6 @@ class Model:
|
|||
def get_chats(self, offset=0, limit=10):
|
||||
return self.chats.get_chats(offset=offset, limit=limit)
|
||||
|
||||
def get_current_msgs(self, offset=0, limit=10):
|
||||
if self.current_chat >= len(self.chats.chat_ids):
|
||||
return []
|
||||
chat_id = self.chats.chat_ids[self.current_chat]
|
||||
return self.msgs.get_msgs(
|
||||
chat_id, offset=offset, limit=limit
|
||||
)
|
||||
|
||||
|
||||
|
||||
class ChatModel:
|
||||
|
||||
|
@ -178,7 +177,7 @@ class MsgModel:
|
|||
return True
|
||||
return False
|
||||
|
||||
def get_msgs(self, chat_id, offset=0, limit=10):
|
||||
def fetch_msgs(self, chat_id, offset=0, limit=10):
|
||||
if offset + limit < len(self.msgs[chat_id]):
|
||||
return sorted(self.msgs[chat_id], key=lambda d: d['id'])[::-1][offset:limit]
|
||||
|
||||
|
|
Loading…
Reference in a new issue