Skip to content

Commit 8af2213

Browse files
committed
boxes: 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 3c764ba commit 8af2213

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

zulipterminal/ui_tools/messages.py

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -676,22 +676,23 @@ def main_view(self) -> List[Any]:
676676

677677
if any_differences: # Construct content_header, if needed
678678
text_keys = ("author", "star", "time", "status")
679-
text: Dict[str, urwid_MarkupTuple] = {key: (None, " ") for key in text_keys}
679+
text: Dict[str, List[urwid_MarkupTuple]] = {
680+
key: [(None, " ")] for key in text_keys
681+
}
680682

681683
if any(
682684
different[key] for key in ("recipients", "author", "author_id", "24h")
683685
):
684686
if self.model.is_user_name_duplicate(message["this"]["author"]):
685-
text["author"] = (
686-
"msg_sender",
687-
message["this"]["author"]
688-
+ " "
689-
+ "("
690-
+ str(message["this"]["author_id"])
691-
+ ")",
692-
)
687+
text["author"] = [
688+
("msg_sender", message["this"]["author"]),
689+
(
690+
"msg_mention",
691+
" " + "(" + str(message["this"]["author_id"]) + ")",
692+
),
693+
]
693694
else:
694-
text["author"] = ("msg_sender", message["this"]["author"])
695+
text["author"] = [("msg_sender", message["this"]["author"])]
695696
# TODO: Refactor to use user ids for look up instead of emails.
696697
email = self.message.get("sender_email", "")
697698
user = self.model.user_dict.get(email, None)
@@ -701,17 +702,17 @@ def main_view(self) -> List[Any]:
701702

702703
# The default text['status'] value is (None, ' ')
703704
if status in STATE_ICON:
704-
text["status"] = (f"user_{status}", STATE_ICON[status])
705+
text["status"] = [(f"user_{status}", STATE_ICON[status])]
705706

706707
if message["this"]["is_starred"]:
707-
text["star"] = ("starred", "*")
708+
text["star"] = [("starred", "*")]
708709
if any(different[key] for key in ("recipients", "author", "timestamp")):
709710
this_year = date.today().year
710711
msg_year = message["this"]["datetime"].year
711712
if this_year != msg_year:
712-
text["time"] = ("time", f"{msg_year} - {message['this']['time']}")
713+
text["time"] = [("time", f"{msg_year} - {message['this']['time']}")]
713714
else:
714-
text["time"] = ("time", message["this"]["time"])
715+
text["time"] = [("time", message["this"]["time"])]
715716

716717
content_header = urwid.Columns(
717718
[

0 commit comments

Comments
 (0)