Skip to content

Commit 2662ae7

Browse files
committed
model: Highlight stream name in reporting of moving/spliting topics.
Partially fixes #1172
1 parent 8d338f5 commit 2662ae7

File tree

2 files changed

+43
-8
lines changed

2 files changed

+43
-8
lines changed

tests/model/test_model.py

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from pytest import param as case
88
from zulip import Client, ZulipError
99

10+
from zulipterminal.config.symbols import STREAM_TOPIC_SEPARATOR
1011
from zulipterminal.helper import initial_index, powerset
1112
from zulipterminal.model import (
1213
MAX_MESSAGE_LENGTH,
@@ -854,7 +855,13 @@ def test_update_private_message(
854855
},
855856
"Old topic",
856857
[
857-
"You changed one message's topic from #stream > Old topic to #stream > Topic change."
858+
"You changed one message's topic from ",
859+
("footer_contrast", f" stream {STREAM_TOPIC_SEPARATOR} "),
860+
("footer_contrast", " Old topic "),
861+
" to ",
862+
("footer_contrast", f" stream {STREAM_TOPIC_SEPARATOR} "),
863+
("footer_contrast", " Topic change "),
864+
" .",
858865
],
859866
),
860867
case(
@@ -885,7 +892,13 @@ def test_update_private_message(
885892
},
886893
"old_terminal",
887894
[
888-
"You changed some messages' topic from #stream > old_terminal to #stream > new_terminal."
895+
"You changed some messages' topic from ",
896+
("footer_contrast", f" stream {STREAM_TOPIC_SEPARATOR} "),
897+
("footer_contrast", " old_terminal "),
898+
" to ",
899+
("footer_contrast", f" stream {STREAM_TOPIC_SEPARATOR} "),
900+
("footer_contrast", " new_terminal "),
901+
" .",
889902
],
890903
),
891904
case(
@@ -897,7 +910,13 @@ def test_update_private_message(
897910
},
898911
"greet",
899912
[
900-
"You changed one message's topic from #stream > greet to #stream > grett."
913+
"You changed one message's topic from ",
914+
("footer_contrast", f" stream {STREAM_TOPIC_SEPARATOR} "),
915+
("footer_contrast", " greet "),
916+
" to ",
917+
("footer_contrast", f" stream {STREAM_TOPIC_SEPARATOR} "),
918+
("footer_contrast", " grett "),
919+
" .",
901920
],
902921
),
903922
case(
@@ -909,7 +928,13 @@ def test_update_private_message(
909928
},
910929
"lets_party",
911930
[
912-
"You changed all messages' topic from #stream > lets_party to #stream > party."
931+
"You changed all messages' topic from ",
932+
("footer_contrast", f" stream {STREAM_TOPIC_SEPARATOR} "),
933+
("footer_contrast", " lets_party "),
934+
" to ",
935+
("footer_contrast", f" stream {STREAM_TOPIC_SEPARATOR} "),
936+
("footer_contrast", " party "),
937+
" .",
913938
],
914939
),
915940
],

zulipterminal/model.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
Subscription,
3737
)
3838
from zulipterminal.config.keys import primary_key_for_command
39+
from zulipterminal.config.symbols import STREAM_TOPIC_SEPARATOR
3940
from zulipterminal.config.ui_mappings import ROLE_BY_ID, StreamAccessType
4041
from zulipterminal.helper import (
4142
Message,
@@ -580,7 +581,12 @@ def update_stream_message(
580581
stream_name = message.get("display_recipient", None)
581582
old_topic = message.get("subject", None)
582583
new_topic = request["topic"]
583-
584+
stream_name_markup = (
585+
"footer_contrast",
586+
f" {stream_name} {STREAM_TOPIC_SEPARATOR} ",
587+
)
588+
old_topic_markup = ("footer_contrast", f" {old_topic} ")
589+
new_topic_markup = ("footer_contrast", f" {new_topic} ")
584590
if old_topic != new_topic:
585591
if propagate_mode == "change_one":
586592
messages_changed = "one message's"
@@ -590,9 +596,13 @@ def update_stream_message(
590596
messages_changed = "some messages'"
591597
self.controller.report_success(
592598
[
593-
f"You changed {messages_changed} topic"
594-
+ f" from #{stream_name} > {old_topic}"
595-
+ f" to #{stream_name} > {new_topic}."
599+
f"You changed {messages_changed} topic from ",
600+
stream_name_markup,
601+
old_topic_markup,
602+
" to ",
603+
stream_name_markup,
604+
new_topic_markup,
605+
" .",
596606
],
597607
duration=6,
598608
)

0 commit comments

Comments
 (0)