Skip to content

Commit 517fd12

Browse files
committed
messages: [To update].
[To update]. Test updated [and added?].
1 parent d8e84b2 commit 517fd12

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

tests/ui_tools/test_messages.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,7 @@ def test_main_view(self, mocker, message, last_message):
766766
[
767767
{
768768
"id": 4,
769+
"sender_id": 4,
769770
"type": "stream",
770771
"display_recipient": "Verona",
771772
"stream_id": 5,
@@ -804,6 +805,7 @@ def test_main_view_renders_slash_me(self, mocker, message, content, is_me_messag
804805
[
805806
{
806807
"id": 4,
808+
"sender_id": 4,
807809
"type": "stream",
808810
"display_recipient": "Verona",
809811
"stream_id": 5,
@@ -1047,6 +1049,7 @@ def test_msg_generates_search_and_header_bar(
10471049
[
10481050
{
10491051
"id": 4,
1052+
"sender_id": 4,
10501053
"type": "stream",
10511054
"display_recipient": "Verona",
10521055
"stream_id": 5,
@@ -1072,11 +1075,11 @@ def test_msg_generates_search_and_header_bar(
10721075
"expected_header, to_vary_in_last_message",
10731076
[
10741077
(
1075-
[STATUS_INACTIVE, "alice", " ", "DAYDATETIME"],
1076-
{"sender_full_name": "bob"},
1078+
[STATUS_INACTIVE, "alice (4)", " ", "DAYDATETIME"],
1079+
{"sender_id": "4"},
10771080
),
10781081
([" ", " ", " ", "DAYDATETIME"], {"timestamp": 1532103779}),
1079-
([STATUS_INACTIVE, "alice", " ", "DAYDATETIME"], {"timestamp": 0}),
1082+
([STATUS_INACTIVE, "alice (4)", " ", "DAYDATETIME"], {"timestamp": 0}),
10801083
],
10811084
ids=[
10821085
"show_author_as_authors_different",
@@ -1172,7 +1175,7 @@ def test_main_view_generates_EDITED_label(
11721175
@pytest.mark.parametrize(
11731176
"to_vary_in_last_message, update_required",
11741177
[
1175-
({"sender_full_name": "Unique name (won't be in next message)"}, True),
1178+
({"sender_id": "Unique id (won't be in next message)"}, True),
11761179
({}, False),
11771180
],
11781181
ids=[

zulipterminal/ui_tools/messages.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -691,8 +691,17 @@ def main_view(self) -> List[Any]:
691691
if any(
692692
different[key] for key in ("recipients", "author", "author_id", "24h")
693693
):
694-
text["author"] = ("msg_sender", message["this"]["author"])
695-
694+
if self.model.is_user_name_duplicate(message["this"]["author"]):
695+
text["author"] = (
696+
"msg_sender",
697+
message["this"]["author"]
698+
+ " "
699+
+ "("
700+
+ str(message["this"]["author_id"])
701+
+ ")",
702+
)
703+
else:
704+
text["author"] = ("msg_sender", message["this"]["author"])
696705
# TODO: Refactor to use user ids for look up instead of emails.
697706
email = self.message.get("sender_email", "")
698707
user = self.model.user_dict.get(email, None)

0 commit comments

Comments
 (0)