mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	refactor: Extract stream_data.clean_up_description().
We use this in the few places where update_calculated_fields() could plausibly be dealing with a new rendered description.
This commit is contained in:
		@@ -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);
 | 
			
		||||
 
 | 
			
		||||
@@ -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),
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user