Skip to content

Commit dc124ec

Browse files
committed
messages: Style any duplicate user-id information in message header.
Apply a style class to user id in header so that user id doesn't look like a part of the username.
1 parent 517fd12 commit dc124ec

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

zulipterminal/ui_tools/messages.py

+15-14
Original file line numberDiff line numberDiff line change
@@ -686,22 +686,23 @@ def main_view(self) -> List[Any]:
686686

687687
if any_differences: # Construct content_header, if needed
688688
text_keys = ("author", "star", "time", "status")
689-
text: Dict[str, urwid_MarkupTuple] = {key: (None, " ") for key in text_keys}
689+
text: Dict[str, List[urwid_MarkupTuple]] = {
690+
key: [(None, " ")] for key in text_keys
691+
}
690692

691693
if any(
692694
different[key] for key in ("recipients", "author", "author_id", "24h")
693695
):
694696
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-
)
697+
text["author"] = [
698+
("msg_sender", message["this"]["author"]),
699+
(
700+
"msg_mention",
701+
f" ({message['this']['author_id']})",
702+
),
703+
]
703704
else:
704-
text["author"] = ("msg_sender", message["this"]["author"])
705+
text["author"] = [("msg_sender", message["this"]["author"])]
705706
# TODO: Refactor to use user ids for look up instead of emails.
706707
email = self.message.get("sender_email", "")
707708
user = self.model.user_dict.get(email, None)
@@ -711,17 +712,17 @@ def main_view(self) -> List[Any]:
711712

712713
# The default text['status'] value is (None, ' ')
713714
if status in STATE_ICON:
714-
text["status"] = (f"user_{status}", STATE_ICON[status])
715+
text["status"] = [(f"user_{status}", STATE_ICON[status])]
715716

716717
if message["this"]["is_starred"]:
717-
text["star"] = ("starred", "*")
718+
text["star"] = [("starred", "*")]
718719
if any(different[key] for key in ("recipients", "author", "timestamp")):
719720
this_year = date.today().year
720721
msg_year = message["this"]["datetime"].year
721722
if this_year != msg_year:
722-
text["time"] = ("time", f"{msg_year} - {message['this']['time']}")
723+
text["time"] = [("time", f"{msg_year} - {message['this']['time']}")]
723724
else:
724-
text["time"] = ("time", message["this"]["time"])
725+
text["time"] = [("time", message["this"]["time"])]
725726

726727
content_header = urwid.Columns(
727728
[

0 commit comments

Comments
 (0)