Skip to content

Commit 8293163

Browse files
committed
views: Display users who've read the message in a sorted list.
Display users who've read the message in a sorted list.
1 parent ebdfae1 commit 8293163

File tree

1 file changed

+48
-24
lines changed

1 file changed

+48
-24
lines changed

zulipterminal/ui_tools/views.py

+48-24
Original file line numberDiff line numberDiff line change
@@ -2001,33 +2001,57 @@ def __init__(
20012001

20022002
# Get read receipt user ids list
20032003
response = controller.model.fetch_read_receipts(message["id"])
2004-
if response is None:
2005-
response = [
2006-
("msg_bold", "RESPONSE CANNOT BE FETCHED AT THE MOMENT. "),
2007-
"\n\nPLEASE TRY AGAIN LATER",
2008-
]
2009-
max_cols = 50
2010-
elif response == "unsupported_ZFL":
2011-
response = [
2004+
if response is None or response == "unsupported_ZFL":
2005+
if response is None:
2006+
response = [
2007+
("msg_bold", "RESPONSE CANNOT BE FETCHED AT THE MOMENT."),
2008+
"\n\nPLEASE TRY AGAIN LATER",
2009+
]
2010+
max_cols = 50
2011+
elif response == "unsupported_ZFL":
2012+
response = [
2013+
(
2014+
"msg_bold",
2015+
"""
2016+
YOUR CURRENT ZT VERSION DOESN'T SUPPORT VIEWING READ RECEIPTS.
2017+
""",
2018+
),
2019+
"\n\nPLEASE UPDATE AND TRY AGAIN LATER",
2020+
]
2021+
max_cols = 70
2022+
2023+
body_list = [urwid.Text(response)]
2024+
2025+
super().__init__(
2026+
controller,
2027+
body_list,
2028+
"MSG_INFO",
2029+
max_cols,
2030+
title,
2031+
)
2032+
else:
2033+
user_names = [controller.model.user_name_from_id(id) for id in response]
2034+
sorted_user_names = sorted(user_names)
2035+
msg_read_list = [("", [(name, "") for name in sorted_user_names])]
2036+
msg_read_list.insert(
2037+
0,
20122038
(
2013-
"msg_bold",
2014-
"YOUR CURRENT ZT VERSION DOESN'T SUPPORT VIEWING READ RECEIPTS. ",
2039+
"",
2040+
[
2041+
(
2042+
f"This message has been read by {len(user_names)} people.",
2043+
"",
2044+
),
2045+
("", ""),
2046+
],
20152047
),
2016-
"\n\nPLEASE UPDATE AND TRY AGAIN LATER",
2017-
]
2018-
max_cols = 70
2019-
else:
2020-
response = str(list(map(controller.model.user_name_from_id, response)))
2021-
2022-
body_list = [urwid.Text(response)]
2048+
)
2049+
popup_width, column_width = self.calculate_table_widths(
2050+
msg_read_list, len(title)
2051+
)
2052+
widgets = self.make_table_with_categories(msg_read_list, column_width)
20232053

2024-
super().__init__(
2025-
controller,
2026-
body_list,
2027-
"MSG_INFO",
2028-
max_cols,
2029-
title,
2030-
)
2054+
super().__init__(controller, widgets, "MSG_INFO", popup_width, title)
20312055

20322056
def keypress(self, size: urwid_Size, key: str) -> str:
20332057
if is_command_key("GO_BACK", key) or is_command_key("READ_RECEIPTS", key):

0 commit comments

Comments
 (0)