diff --git a/tg/controllers/__init__.py b/tg/controllers/__init__.py index 0a4d20a..c492369 100644 --- a/tg/controllers/__init__.py +++ b/tg/controllers/__init__.py @@ -159,6 +159,7 @@ class Controller: def handle_msgs(self) -> str: self.chat_size = 0.2 self.resize() + self.model.view_current_msg() while True: diff --git a/tg/models/__init__.py b/tg/models/__init__.py index 78626d4..4a5fa86 100644 --- a/tg/models/__init__.py +++ b/tg/models/__init__.py @@ -76,15 +76,19 @@ class Model: return True return False + def view_current_msg(self): + chat_id = self.chats.id_by_index(self.current_chat) + msg = MsgProxy(self.current_msg()) + msg_id = msg["id"] + self.tg.view_messages(chat_id, [msg_id]) + def next_msg(self, step: int = 1) -> bool: chat_id = self.chats.id_by_index(self.current_chat) if not chat_id: return False is_next = self.msgs.next_msg(chat_id, step) if is_next: - msg = MsgProxy(self.current_msg()) - msg_id = msg["id"] - self.tg.view_messages(chat_id, [msg_id]) + self.view_current_msg() return is_next def prev_msg(self, step: int = 1) -> bool: @@ -93,9 +97,7 @@ class Model: return False is_prev = self.msgs.prev_msg(chat_id, step) if is_prev: - msg = MsgProxy(self.current_msg()) - msg_id = msg["id"] - self.tg.view_messages(chat_id, [msg_id]) + self.view_current_msg() return is_prev def get_chats(