Skip to content

Commit 35ad81b

Browse files
committed
buttons/views/symbols: Use varying symbols for user status.
This moves from having a single small bullet to a style similar to the webapp, with circles of varying degrees of fullness: * filled (active) * bottom-filled (idle) * empty (offline) * small (inactive) These are listed most clearly in symbols.py. Tests updated.
1 parent 617c4c5 commit 35ad81b

File tree

5 files changed

+28
-7
lines changed

5 files changed

+28
-7
lines changed

tests/conftest.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@ def user_button(mocker, width=38):
6363
},
6464
width=width,
6565
controller=mocker.patch('zulipterminal.core.Controller'),
66-
view=mocker.patch('zulipterminal.ui.View')
66+
view=mocker.patch('zulipterminal.ui.View'),
67+
state_marker="*",
6768
)
6869

6970

tests/ui/test_ui_tools.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99

1010
from zulipterminal.config.keys import keys_for_command
1111
from zulipterminal.config.symbols import (
12-
QUOTED_TEXT_MARKER, STREAM_TOPIC_SEPARATOR, TIME_MENTION_MARKER,
12+
QUOTED_TEXT_MARKER, STATUS_ACTIVE, STREAM_TOPIC_SEPARATOR,
13+
TIME_MENTION_MARKER,
1314
)
1415
from zulipterminal.helper import powerset
1516
from zulipterminal.ui_tools.boxes import MessageBox
@@ -1128,6 +1129,7 @@ def test_users_view(self, users, users_btn_len, editor_mode, status,
11281129
view=self.view,
11291130
width=width,
11301131
color='user_' + self.view.users[0]['status'],
1132+
state_marker=STATUS_ACTIVE,
11311133
count=1,
11321134
is_current_user=False
11331135
)
@@ -2313,11 +2315,12 @@ def test_text_content(self, mocker,
23132315
view=mocker.Mock(),
23142316
width=width,
23152317
color=None, # FIXME test elsewhere?
2318+
state_marker="*",
23162319
count=count)
23172320

23182321
text = user_button._w._original_widget.get_text()
23192322
count_str = '' if count == 0 else str(count)
2320-
expected_text = ' \N{BULLET} {}{}{}'.format(
2323+
expected_text = ' * {}{}{}'.format(
23212324
short_text,
23222325
(width - 4 - len(short_text) - len(count_str)) * ' ',
23232326
count_str)
@@ -2342,6 +2345,7 @@ def test_activate_called_once_on_keypress(
23422345
view=mocker.Mock(),
23432346
width=width,
23442347
color=mocker.Mock(),
2348+
state_marker="*",
23452349
count=mocker.Mock())
23462350
size = widget_size(user_button)
23472351

zulipterminal/config/symbols.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@
1111
# appears to overlap its subsequent text.
1212
TIME_MENTION_MARKER = '⏱ ' # Other tested options are: '⧗' and '⧖'.
1313
MUTE_MARKER = 'M'
14+
STATUS_ACTIVE = '●'
15+
STATUS_IDLE = '◒'
16+
STATUS_OFFLINE = '○'
17+
STATUS_INACTIVE = '•'

zulipterminal/ui_tools/buttons.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
203203
class UserButton(TopButton):
204204
def __init__(self, user: Dict[str, Any], controller: Any,
205205
view: Any, width: int,
206+
state_marker: str,
206207
color: Optional[str]=None, count: int=0,
207208
is_current_user: bool=False) -> None:
208209
# Properties accessed externally
@@ -217,7 +218,7 @@ def __init__(self, user: Dict[str, Any], controller: Any,
217218
super().__init__(controller,
218219
caption=user['full_name'],
219220
show_function=self._narrow_with_compose,
220-
prefix_character=(color, '\N{BULLET}'),
221+
prefix_character=(color, state_marker),
221222
text_color=color,
222223
width=width,
223224
count=count)

zulipterminal/ui_tools/views.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
HELP_CATEGORIES, KEY_BINDINGS, is_command_key, keys_for_command,
1111
)
1212
from zulipterminal.config.symbols import (
13-
CHECK_MARK, LIST_TITLE_BAR_LINE, PINNED_STREAMS_DIVIDER,
13+
CHECK_MARK, LIST_TITLE_BAR_LINE, PINNED_STREAMS_DIVIDER, STATUS_ACTIVE,
14+
STATUS_IDLE, STATUS_INACTIVE, STATUS_OFFLINE,
1415
)
1516
from zulipterminal.helper import (
1617
Message, asynch, edit_mode_captions, match_stream, match_user,
@@ -651,10 +652,19 @@ def users_view(self, users: Any=None) -> Any:
651652
if users is None:
652653
users = self.view.users.copy()
653654
reset_default_view_users = True
655+
656+
state_icon = {
657+
'active': STATUS_ACTIVE,
658+
'idle': STATUS_IDLE,
659+
'offline': STATUS_OFFLINE,
660+
'inactive': STATUS_INACTIVE,
661+
}
662+
654663
users_btn_list = list()
655664
for user in users:
665+
status = user['status']
656666
# Only include `inactive` users in search result.
657-
if (user['status'] == 'inactive'
667+
if (status == 'inactive'
658668
and not self.view.controller.is_in_editor_mode()):
659669
continue
660670
unread_count = (self.view.model.unread_counts['unread_pms'].
@@ -666,7 +676,8 @@ def users_view(self, users: Any=None) -> Any:
666676
controller=self.view.controller,
667677
view=self.view,
668678
width=self.width,
669-
color='user_' + user['status'],
679+
state_marker=state_icon[status],
680+
color='user_' + status,
670681
count=unread_count,
671682
is_current_user=is_current_user
672683
)

0 commit comments

Comments
 (0)