Skip to content

Commit fca75c4

Browse files
committed
boxes: Add status marker as a suffix to sender name in content header.
This commit adds a status marker right after the sender's name in a message content header. The users' dict from model is used to get status of the sender. The default status of sender is kept `inactive`. NOTE: Currently, * the status markers don't get updated regularly (only specific updates for events `handle_update_message_event`), and * 'all' the message headers (markers) don't get updated, which would need implementing their handling in separate commits. (potentially amending `start_presence_updates`) Tests amended. Fixes zulip#896.
1 parent 90721d4 commit fca75c4

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

tests/ui/test_ui_tools.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from zulipterminal.config.symbols import (
1212
QUOTED_TEXT_MARKER,
1313
STATUS_ACTIVE,
14+
STATUS_INACTIVE,
1415
STREAM_TOPIC_SEPARATOR,
1516
TIME_MENTION_MARKER,
1617
)
@@ -1784,9 +1785,11 @@ def test_msg_generates_search_and_header_bar(self, mocker,
17841785
@pytest.mark.parametrize('starred_msg', ['this', 'last', 'neither'],
17851786
ids=['this_starred', 'last_starred', 'no_stars'])
17861787
@pytest.mark.parametrize('expected_header, to_vary_in_last_message', [
1787-
(['alice', ' ', 'DAYDATETIME'], {'sender_full_name': 'bob'}),
1788-
([' ', ' ', 'DAYDATETIME'], {'timestamp': 1532103779}),
1789-
(['alice', ' ', 'DAYDATETIME'], {'timestamp': 0}),
1788+
(['alice', STATUS_INACTIVE, ' ', 'DAYDATETIME'],
1789+
{'sender_full_name': 'bob'}),
1790+
([' ', ' ', ' ', 'DAYDATETIME'], {'timestamp': 1532103779}),
1791+
(['alice', STATUS_INACTIVE, ' ', 'DAYDATETIME'],
1792+
{'timestamp': 0}),
17901793
], ids=['show_author_as_authors_different',
17911794
'merge_messages_as_only_slightly_earlier_message',
17921795
'dont_merge_messages_as_much_earlier_message'])
@@ -1813,10 +1816,10 @@ def test_main_view_content_header_without_header(self, mocker, message,
18131816

18141817
msg_box = MessageBox(this_msg, self.model, last_msg)
18151818

1816-
expected_header[1] = output_date_time
1819+
expected_header[2] = output_date_time
18171820
if current_year > 2018:
1818-
expected_header[1] = '2018 - ' + expected_header[1]
1819-
expected_header[2] = '*' if starred_msg == 'this' else ' '
1821+
expected_header[2] = '2018 - ' + expected_header[2]
1822+
expected_header[3] = '*' if starred_msg == 'this' else ' '
18201823

18211824
view_components = msg_box.main_view()
18221825

zulipterminal/ui_tools/boxes.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
TIME_MENTION_MARKER,
3737
)
3838
from zulipterminal.helper import (
39+
STATE_ICON,
3940
Message,
4041
asynch,
4142
format_string,
@@ -1188,11 +1189,19 @@ def main_view(self) -> List[Any]:
11881189

11891190
if any_differences: # Construct content_header, if needed
11901191
TextType = Dict[str, Tuple[Optional[str], str]]
1191-
text_keys = ('author', 'star', 'time')
1192+
text_keys = ('author', 'star', 'time', 'status')
11921193
text: TextType = {key: (None, ' ') for key in text_keys}
11931194

11941195
if any(different[key] for key in ('recipients', 'author', '24h')):
11951196
text['author'] = ('name', message['this']['author'])
1197+
1198+
users = self.model.users.copy()
1199+
status = next(iter(
1200+
user['status'] for user in users
1201+
if user['full_name'] == message['this']['author']
1202+
), 'inactive')
1203+
text['status'] = (f"user_{status}", STATE_ICON[status])
1204+
11961205
if message['this']['is_starred']:
11971206
text['star'] = ('starred', "*")
11981207
if any(different[key]
@@ -1208,7 +1217,8 @@ def main_view(self) -> List[Any]:
12081217
text['time'] = ('time', message['this']['time'])
12091218

12101219
content_header = urwid.Columns([
1211-
('weight', 10, urwid.Text(text['author'])),
1220+
('pack', urwid.Text(text['author'])),
1221+
('weight', 1, urwid.Text(text['status'])),
12121222
(26, urwid.Text(text['time'], align='right')),
12131223
(1, urwid.Text(text['star'], align='right')),
12141224
], dividechars=1)

0 commit comments

Comments
 (0)