onboarding: Use 'remove_single_newlines' once, while sending message.

Instead of applying 'remove_single_newlines()' to individual
contents when declared, we use it once while prepping up
message in 'internal_prep_stream_message_by_name'.

Just for the code to be less finnicky.
This commit is contained in:
Prakhar Pratyush 2024-05-12 09:24:25 +05:30 committed by Tim Abbott
parent 3d8802b276
commit 15a7870d2e
1 changed files with 20 additions and 32 deletions

View File

@ -276,18 +276,16 @@ def send_initial_realm_messages(realm: Realm) -> None:
#
# remove_single_newlines needs to be called on any multiline
# strings for them to render properly.
content1_of_moving_messages_topic_name = remove_single_newlines(
(
_("""
content1_of_moving_messages_topic_name = (
_("""
If anything is out of place, its easy to [move messages]({move_content_another_topic_help_url}),
[rename]({rename_topic_help_url}) and [split]({move_content_another_topic_help_url}) topics,
or even move a topic [to a different channel]({move_content_another_channel_help_url}).
""")
).format(
move_content_another_topic_help_url="/help/move-content-to-another-topic",
rename_topic_help_url="/help/rename-a-topic",
move_content_another_channel_help_url="/help/move-content-to-another-channel",
)
).format(
move_content_another_topic_help_url="/help/move-content-to-another-topic",
rename_topic_help_url="/help/rename-a-topic",
move_content_another_channel_help_url="/help/move-content-to-another-channel",
)
content2_of_moving_messages_topic_name = _("""
@ -298,42 +296,34 @@ or even move a topic [to a different channel]({move_content_another_channel_help
Zulip is organized to help you communicate more efficiently.
""")
content2_of_welcome_to_zulip_topic_name = remove_single_newlines(
(
_("""
content2_of_welcome_to_zulip_topic_name = (
_("""
In Zulip, **channels** determine who gets a message.
Each conversation in a channel is labeled with a **topic**. This message is in
the #**{zulip_discussion_channel_name}** channel, in the "{topic_name}" topic, as you can
see in the left sidebar and above.
""")
).format(
zulip_discussion_channel_name=str(Realm.ZULIP_DISCUSSION_CHANNEL_NAME),
topic_name=_("welcome to Zulip!"),
)
).format(
zulip_discussion_channel_name=str(Realm.ZULIP_DISCUSSION_CHANNEL_NAME),
topic_name=_("welcome to Zulip!"),
)
content3_of_welcome_to_zulip_topic_name = remove_single_newlines(
_("""
content3_of_welcome_to_zulip_topic_name = _("""
You can read Zulip one conversation at a time, seeing each message in context,
no matter how many other conversations are going on.
""")
)
content4_of_welcome_to_zulip_topic_name = remove_single_newlines(
_("""
content4_of_welcome_to_zulip_topic_name = _("""
:point_right: When you're ready, check out your [Inbox](/#inbox) for other
conversations with unread messages. You can come back to this conversation
if you need to from your **Starred** messages.
""")
)
content1_of_start_conversation_topic_name = remove_single_newlines(
_("""
content1_of_start_conversation_topic_name = _("""
To kick off a new conversation, click **Start new conversation** below.
The new conversation thread wont interrupt ongoing discussions.
""")
)
content2_of_start_conversation_topic_name = _("""
For a good topic name, think about finishing the sentence: Hey, can we chat about?
@ -376,9 +366,8 @@ This **greetings** topic is a great place to say "hi" :wave: to your teammates.
:point_right: Click on any message to start a reply in the same topic.
""")
content_of_zulip_update_announcements_topic_name = remove_single_newlines(
(
_("""
content_of_zulip_update_announcements_topic_name = (
_("""
Welcome! To help you learn about new features and configuration options,
this topic will receive messages about important changes in Zulip.
@ -387,10 +376,9 @@ You can read these update messages whenever it's convenient, or
If your organization does not want to receive these announcements,
they can be disabled. [Learn more]({zulip_update_announcements_help_url}).
""")
).format(
zulip_update_announcements_help_url="/help/configure-automated-notices#zulip-update-announcements",
mute_topic_help_url="/help/mute-a-topic",
)
).format(
zulip_update_announcements_help_url="/help/configure-automated-notices#zulip-update-announcements",
mute_topic_help_url="/help/mute-a-topic",
)
welcome_messages: List[Dict[str, str]] = []
@ -482,7 +470,7 @@ they can be disabled. [Learn more]({zulip_update_announcements_help_url}).
welcome_bot,
message["channel_name"],
message["topic_name"],
message["content"],
remove_single_newlines(message["content"]),
)
for message in welcome_messages
]