Skip to content

Commit 1d41edd

Browse files
committed
views: Rework direct messages button UI.
This commit reworks the direct messages button by moving it to a different section between the menu and the streams panel. This is done in preparation for the addition of a direct messages panel showing the DM's with different users.
1 parent 91d11b2 commit 1d41edd

File tree

1 file changed

+15
-8
lines changed

1 file changed

+15
-8
lines changed

zulipterminal/ui_tools/views.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -763,19 +763,17 @@ def __init__(self, view: Any) -> None:
763763
self.view = view
764764
self.controller = view.controller
765765
self.menu_v = self.menu_view()
766+
self.pm_v = self.pm_view()
766767
self.stream_v = self.streams_view()
767768
self.stream_panel = self.streams_panel(self.stream_v)
768769
self.is_in_topic_view = False
769-
contents = [(4, self.menu_v), self.stream_panel]
770+
contents = [(3, self.menu_v), (2, self.pm_v), self.stream_panel]
770771
super().__init__(contents)
771772

772773
def menu_view(self) -> Any:
773774
count = self.model.unread_counts.get("all_msg", 0)
774775
self.view.home_button = HomeButton(controller=self.controller, count=count)
775776

776-
count = self.model.unread_counts.get("all_pms", 0)
777-
self.view.pm_button = PMButton(controller=self.controller, count=count)
778-
779777
self.view.mentioned_button = MentionedButton(
780778
controller=self.controller,
781779
count=self.model.unread_counts["all_mentions"],
@@ -788,7 +786,6 @@ def menu_view(self) -> Any:
788786
)
789787
menu_btn_list = [
790788
self.view.home_button,
791-
self.view.pm_button,
792789
self.view.mentioned_button,
793790
self.view.starred_button,
794791
]
@@ -810,6 +807,16 @@ def streams_panel(self, submenu_view: Any) -> Any:
810807
)
811808
return w
812809

810+
def pm_view(self) -> Any:
811+
count = self.model.unread_counts.get("all_pms", 0)
812+
self.view.pm_button = PMButton(controller=self.controller, count=count)
813+
self.view.pm_w = urwid.ListBox(
814+
urwid.SimpleFocusListWalker(
815+
[urwid.Divider(div_char=COLUMN_TITLE_BAR_LINE), self.view.pm_button]
816+
)
817+
)
818+
return self.view.pm_w
819+
813820
def streams_view(self) -> Any:
814821
streams_btn_list = [
815822
StreamButton(
@@ -889,12 +896,12 @@ def update_stream_view(self) -> None:
889896
def show_stream_view(self) -> None:
890897
self.is_in_topic_view = False
891898
self.stream_panel = self.streams_panel(self.stream_v)
892-
self.contents[1] = (self.stream_panel, self.options(height_type="weight"))
899+
self.contents[2] = (self.stream_panel, self.options(height_type="weight"))
893900

894901
def show_topic_view(self, stream_button: Any) -> None:
895902
self.is_in_topic_view = True
896903
self.stream_panel = self.streams_panel(self.topics_view(stream_button))
897-
self.contents[1] = (
904+
self.contents[2] = (
898905
self.stream_panel,
899906
self.options(height_type="weight"),
900907
)
@@ -903,7 +910,7 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
903910
if is_command_key("SEARCH_STREAMS", key) or is_command_key(
904911
"SEARCH_TOPICS", key
905912
):
906-
self.focus_position = 1
913+
self.focus_position = 2
907914
if self.is_in_topic_view:
908915
self.view.topic_w.keypress(size, key)
909916
else:

0 commit comments

Comments
 (0)