From d3297e205c83da4cbf7095cc1697d50d75ae88cd Mon Sep 17 00:00:00 2001 From: Niloth-p <20315308+Niloth-p@users.noreply.github.com> Date: Thu, 6 Jun 2024 06:53:08 +0530 Subject: [PATCH] views: Make the ALL_MESSAGES command work globally. This command worked only when a message was selected, using it as an anchor to fetch messages. Now, it has been made consistent with the other menu button commands, to work from any panel. This could not be implemented in ui.py along with other menu buttons, because of the conflict caused by the Esc key also being assigned to reset search in the side panels (GO_BACK command). When both operations, 1. reset search in the current panel view 2. narrow to all messages are possible, pressing `Esc` is set to trigger only the reset search operation and not the ALL_MESSAGES command. The next keypress of `Esc` will go to the home view once the current panel view is restored to its default state. Fixes #1505. --- zulipterminal/ui_tools/views.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/zulipterminal/ui_tools/views.py b/zulipterminal/ui_tools/views.py index e7d5d007cf..4c23cba861 100644 --- a/zulipterminal/ui_tools/views.py +++ b/zulipterminal/ui_tools/views.py @@ -415,6 +415,11 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]: self.search_status = SearchStatus.DEFAULT self.view.controller.update_screen() return key + elif is_command_key("ALL_MESSAGES", key): + self.view.controller.narrow_to_all_messages() + self.view.show_left_panel(visible=False) + self.view.body.focus_position = 1 + return key return super().keypress(size, key) @@ -543,6 +548,11 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]: self.search_status = SearchStatus.DEFAULT self.view.controller.update_screen() return key + elif is_command_key("ALL_MESSAGES", key): + self.view.controller.narrow_to_all_messages() + self.view.show_left_panel(visible=False) + self.view.body.focus_position = 1 + return key return super().keypress(size, key) @@ -790,6 +800,11 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]: self.search_status = SearchStatus.DEFAULT self.view.controller.update_screen() return key + elif is_command_key("ALL_MESSAGES", key): + self.view.controller.narrow_to_all_messages() + self.view.show_right_panel(visible=False) + self.view.body.focus_position = 1 + return key elif is_command_key("GO_LEFT", key): self.view.show_right_panel(visible=False) return super().keypress(size, key)