Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

refactor: Extract stream_data.clean_up_description().

Steve Howell5624ed2afe59
diff --git a/static/js/stream_data.js b/static/js/stream_data.js
index e59c5e42b14..486da7ee0a3 100644
--- a/static/js/stream_data.js
+++ b/static/js/stream_data.js
@@ -631,6 +631,12 @@ export function create_streams(streams) {
}
}
+export function clean_up_description(sub) {
+ if (sub.rendered_description !== undefined) {
+ sub.rendered_description = sub.rendered_description.replace("<p>", "").replace("</p>", "");
+ }
+}
+
export function create_sub_from_server_data(attrs) {
if (!attrs.stream_id) {
// fail fast
@@ -680,6 +686,7 @@ export function create_sub_from_server_data(attrs) {
// TODO: Let stream settings code add these fields.
stream_settings_data.update_calculated_fields(sub);
+ clean_up_description(sub);
stream_info.set(sub.name, sub);
subs_by_stream_id.set(sub.stream_id, sub);
diff --git a/static/js/stream_edit.js b/static/js/stream_edit.js
index 3967a610072..4f72ff44e48 100644
--- a/static/js/stream_edit.js
+++ b/static/js/stream_edit.js
@@ -436,6 +436,7 @@ export function show_settings_for(node) {
const sub = stream_data.get_sub_by_id(stream_id);
stream_settings_data.update_calculated_fields(sub);
+ stream_data.clean_up_description(sub);
const html = render_subscription_settings({
sub,
settings: stream_settings(sub),
diff --git a/static/js/stream_settings_data.js b/static/js/stream_settings_data.js
index 024a909e0f3..c7811f63ad3 100644
--- a/static/js/stream_settings_data.js
+++ b/static/js/stream_settings_data.js
@@ -60,10 +60,6 @@ export function update_calculated_fields(sub) {
sub.preview_url = hash_util.by_stream_uri(sub.stream_id);
sub.is_old_stream = sub.stream_weekly_traffic !== null;
- if (sub.rendered_description !== undefined) {
- sub.rendered_description = sub.rendered_description.replace("<p>", "").replace("</p>", "");
- }
-
// Apply the defaults for our notification settings for rendering.
for (const setting of settings_config.stream_specific_notification_settings) {
sub[setting + "_display"] = stream_data.receives_notifications(sub.stream_id, setting);
diff --git a/static/js/subs.js b/static/js/subs.js
index cc11283716c..569a2300b63 100644
--- a/static/js/subs.js
+++ b/static/js/subs.js
@@ -209,7 +209,8 @@ export function update_stream_name(sub, new_name) {
export function update_stream_description(sub, description, rendered_description) {
sub.description = description;
- sub.rendered_description = rendered_description.replace("<p>", "").replace("</p>", "");
+ sub.rendered_description = rendered_description;
+ stream_data.clean_up_description(sub);
// Update stream row
const sub_row = row_for_stream_id(sub.stream_id);