mirror of
				https://github.com/zulip/zulip.git
				synced 2025-10-31 12:03:46 +00:00 
			
		
		
		
	left_sidebar: Fully rerender stream list when count display policy changes.
Now that there are many counts to update, we may as well just rerender the whole stream list.
This commit is contained in:
		| @@ -957,7 +957,7 @@ export function dispatch_normal_event(event) { | |||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|             if (event.property === "web_stream_unreads_count_display_policy") { |             if (event.property === "web_stream_unreads_count_display_policy") { | ||||||
|                 stream_list.update_dom_unread_counts_visibility(); |                 stream_list.build_stream_list(true); | ||||||
|             } |             } | ||||||
|             if (event.property === "user_list_style") { |             if (event.property === "user_list_style") { | ||||||
|                 settings_preferences.report_user_list_style_change( |                 settings_preferences.report_user_list_style_change( | ||||||
|   | |||||||
| @@ -685,25 +685,6 @@ function toggle_hide_unread_counts( | |||||||
|     $subscription_block.toggleClass("hide_unread_counts", hide_count); |     $subscription_block.toggleClass("hide_unread_counts", hide_count); | ||||||
| } | } | ||||||
|  |  | ||||||
| export function update_dom_unread_counts_visibility(): void { |  | ||||||
|     // TODO: It's not obviously why this function exists; can't we |  | ||||||
|     // just do a full left sidebar rebuild? |  | ||||||
|     for (const stream of stream_sidebar.rows.values()) { |  | ||||||
|         const $subscription_block = stream.get_li().find(".subscription_block"); |  | ||||||
|  |  | ||||||
|         const is_muted = stream_data.is_muted(stream.sub.stream_id); |  | ||||||
|         // Technically, we just need to know if there's at least one |  | ||||||
|         // unmuted unread here, so this could be optimized by using a |  | ||||||
|         // faster `unread.ts` API optimized to compute just the set of |  | ||||||
|         // channels with at least one unmuted unread. |  | ||||||
|         // |  | ||||||
|         // That optimization is inessential as long as this function |  | ||||||
|         // is only called when changing a global personal setting. |  | ||||||
|         const stream_counts = unread.unread_count_info_for_stream(stream.sub.stream_id); |  | ||||||
|         toggle_hide_unread_counts($subscription_block, is_muted, stream_counts.unmuted_count); |  | ||||||
|     } |  | ||||||
| } |  | ||||||
|  |  | ||||||
| export function rename_stream(sub: StreamSubscription): void { | export function rename_stream(sub: StreamSubscription): void { | ||||||
|     // The sub object is expected to already have the updated name |     // The sub object is expected to already have the updated name | ||||||
|     build_stream_sidebar_row(sub); |     build_stream_sidebar_row(sub); | ||||||
|   | |||||||
| @@ -1286,7 +1286,7 @@ run_test("user_settings", ({override}) => { | |||||||
|     { |     { | ||||||
|         const stub = make_stub(); |         const stub = make_stub(); | ||||||
|         event = event_fixtures.user_settings__web_stream_unreads_count_display_policy; |         event = event_fixtures.user_settings__web_stream_unreads_count_display_policy; | ||||||
|         override(stream_list, "update_dom_unread_counts_visibility", stub.f); |         override(stream_list, "build_stream_list", stub.f); | ||||||
|         override(user_settings, "web_stream_unreads_count_display_policy", 1); |         override(user_settings, "web_stream_unreads_count_display_policy", 1); | ||||||
|         dispatch(event); |         dispatch(event); | ||||||
|         assert.equal(stub.num_calls, 1); |         assert.equal(stub.num_calls, 1); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user