Skip to content

Commit 748cb4a

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 e0d9694 commit 748cb4a

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
@@ -773,19 +773,17 @@ def __init__(self, view: Any) -> None:
773773
self.view = view
774774
self.controller = view.controller
775775
self.menu_v = self.menu_view()
776+
self.pm_v = self.pm_view()
776777
self.stream_v = self.streams_view()
777778

778779
self.is_in_topic_view = False
779-
contents = [(4, self.menu_v), self.stream_v]
780+
contents = [(3, self.menu_v), (2, self.pm_v), self.stream_v]
780781
super().__init__(contents)
781782

782783
def menu_view(self) -> Any:
783784
count = self.model.unread_counts.get("all_msg", 0)
784785
self.view.home_button = HomeButton(controller=self.controller, count=count)
785786

786-
count = self.model.unread_counts.get("all_pms", 0)
787-
self.view.pm_button = PMButton(controller=self.controller, count=count)
788-
789787
self.view.mentioned_button = MentionedButton(
790788
controller=self.controller,
791789
count=self.model.unread_counts["all_mentions"],
@@ -798,13 +796,22 @@ def menu_view(self) -> Any:
798796
)
799797
menu_btn_list = [
800798
self.view.home_button,
801-
self.view.pm_button,
802799
self.view.mentioned_button,
803800
self.view.starred_button,
804801
]
805802
w = urwid.ListBox(urwid.SimpleFocusListWalker(menu_btn_list))
806803
return w
807804

805+
def pm_view(self) -> Any:
806+
count = self.model.unread_counts.get("all_pms", 0)
807+
self.view.pm_button = PMButton(controller=self.controller, count=count)
808+
self.view.pm_w = urwid.ListBox(
809+
urwid.SimpleFocusListWalker(
810+
[urwid.Divider(div_char=COLUMN_TITLE_BAR_LINE), self.view.pm_button]
811+
)
812+
)
813+
return self.view.pm_w
814+
808815
def streams_view(self) -> Any:
809816
streams_btn_list = [
810817
StreamButton(
@@ -894,11 +901,11 @@ def update_stream_view(self) -> None:
894901

895902
def show_stream_view(self) -> None:
896903
self.is_in_topic_view = False
897-
self.contents[1] = (self.stream_v, self.options(height_type="weight"))
904+
self.contents[2] = (self.stream_v, self.options(height_type="weight"))
898905

899906
def show_topic_view(self, stream_button: Any) -> None:
900907
self.is_in_topic_view = True
901-
self.contents[1] = (
908+
self.contents[2] = (
902909
self.topics_view(stream_button),
903910
self.options(height_type="weight"),
904911
)
@@ -907,7 +914,7 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
907914
if is_command_key("SEARCH_STREAMS", key) or is_command_key(
908915
"SEARCH_TOPICS", key
909916
):
910-
self.focus_position = 1
917+
self.focus_position = 2
911918
if self.is_in_topic_view:
912919
self.view.topic_w.keypress(size, key)
913920
else:

0 commit comments

Comments
 (0)