Fix bugs in the patch

This commit is contained in:
Paul Nameless 2020-05-22 14:13:35 +08:00
parent b6c9916fcc
commit e2df1bd5f3
2 changed files with 4 additions and 4 deletions

View file

@ -104,13 +104,13 @@ class Controller:
"p": lambda _: self.forward_msgs(), "p": lambda _: self.forward_msgs(),
} }
def forward_msgs(self, _: int): def forward_msgs(self):
# TODO: check <can_be_forwarded> flag # TODO: check <can_be_forwarded> flag
chat_id = self.model.chats.id_by_index(self.model.current_chat) chat_id = self.model.chats.id_by_index(self.model.current_chat)
if not chat_id: if not chat_id:
return return
from_chat_id, msg_ids = self.model.yanked_msgs from_chat_id, msg_ids = self.model.yanked_msgs
if from_chat_id is None: if not msg_ids:
return return
self.tg.forward_msgs(chat_id, from_chat_id, msg_ids) self.tg.forward_msgs(chat_id, from_chat_id, msg_ids)
self.present_info(f"Forwarded {len(msg_ids)} messages") self.present_info(f"Forwarded {len(msg_ids)} messages")
@ -139,7 +139,6 @@ class Controller:
self.model.selected[chat_id].append(msg.msg_id) self.model.selected[chat_id].append(msg.msg_id)
self.model.next_msg() self.model.next_msg()
self.refresh_msgs() self.refresh_msgs()
self.present_info("Removed selections")
def discard_selected_msgs(self): def discard_selected_msgs(self):
chat_id = self.model.chats.id_by_index(self.model.current_chat) chat_id = self.model.chats.id_by_index(self.model.current_chat)
@ -147,6 +146,7 @@ class Controller:
return return
self.model.selected[chat_id] = [] self.model.selected[chat_id] = []
self.refresh_msgs() self.refresh_msgs()
self.present_info("Discarded selected messages")
def jump_bottom(self): def jump_bottom(self):
if self.model.jump_bottom(): if self.model.jump_bottom():

View file

@ -17,7 +17,7 @@ class Model:
self.current_chat = 0 self.current_chat = 0
self.downloads: Dict[int, Tuple[int, int]] = {} self.downloads: Dict[int, Tuple[int, int]] = {}
self.selected: Dict[int, List[int]] = defaultdict(list) self.selected: Dict[int, List[int]] = defaultdict(list)
self.yanked_msgs: Tuple[Optional[int], List[int]] = (None, []) self.yanked_msgs: Tuple[int, List[int]] = (0, [])
def get_me(self): def get_me(self):
return self.users.get_me() return self.users.get_me()