Skip to content

Commit

Permalink
views: Make the ALL_MESSAGES command work globally.
Browse files Browse the repository at this point in the history
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 zulip#1505.
  • Loading branch information
Niloth-p committed Jun 6, 2024
1 parent 4258831 commit d3297e2
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions zulipterminal/ui_tools/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down Expand Up @@ -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)


Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit d3297e2

Please sign in to comment.