Skip to content

Commit b78cc81

Browse files
committed
model/views: Add method to regularly update state markers in messages.
This commit: * introduces a method `update_msg_list_presence_markers` in middle column view class. It would be responsible for rendering the status markers (if present) in message list. * adds presence renderer function to the handler `start_presence_updates`. This way, the method `update_msg_list_presence_markers` is called every minute. The helper `update_msg_list_presence_markers` uses MessageBox class method `update_msg_content_header` (added in previous commit) to update a message box (if required). Fixes zulip#896.
1 parent 3efd63b commit b78cc81

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

zulipterminal/model.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -341,9 +341,9 @@ def _start_presence_updates(self) -> None:
341341
self.initial_data["presences"] = response["presences"]
342342
self.users = self.get_all_users()
343343
if hasattr(self.controller, "view"):
344-
self.controller.view.users_view.update_user_list(
345-
user_list=self.users
346-
)
344+
view = self.controller.view
345+
view.users_view.update_user_list(user_list=self.users)
346+
view.middle_column.update_msg_list_presence_markers()
347347
time.sleep(60)
348348

349349
@asynch

zulipterminal/ui_tools/views.py

+12
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,18 @@ def get_next_unread_pm(self) -> Optional[int]:
555555
return pm
556556
return None
557557

558+
def update_msg_list_presence_markers(self) -> None:
559+
for index in range(len(self.body.log)):
560+
msg_btn = self.body.log[index]
561+
562+
# Update a message box content header if required.
563+
msg_btn.original_widget.update_msg_content_header()
564+
565+
# Render the modified message list
566+
self.body.log[index] = msg_btn
567+
568+
self.controller.update_screen()
569+
558570
def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
559571
if is_command_key("GO_BACK", key):
560572
self.header.keypress(size, "esc")

0 commit comments

Comments
 (0)