mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	ui_util: Use .show and .hide classes for unread counts visibility.
				
					
				
			This is a prep commit for introducing new "Show unread counts for" user display setting. We should use css classes like `.hide` to hide the unread count from the DOM as opposed to using `$unread_count_span.hide()` because this injects inline styles and hence we won't be able to change the `display` style on hovering for unread counts.
This commit is contained in:
		@@ -51,12 +51,12 @@ export function update_unread_count_in_dom($unread_count_elem: JQuery, count: nu
 | 
			
		||||
    const $unread_count_span = $unread_count_elem.find(".unread_count");
 | 
			
		||||
 | 
			
		||||
    if (count === 0) {
 | 
			
		||||
        $unread_count_span.hide();
 | 
			
		||||
        $unread_count_span.addClass("hide");
 | 
			
		||||
        $unread_count_span.text("");
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    $unread_count_span.show();
 | 
			
		||||
    $unread_count_span.removeClass("hide");
 | 
			
		||||
    $unread_count_span.text(count);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -28,7 +28,7 @@ run_test("update_dom_with_unread_counts", () => {
 | 
			
		||||
 | 
			
		||||
    pm_list.set_count(counts.private_message_count);
 | 
			
		||||
    assert.equal($total_count.text(), "10");
 | 
			
		||||
    assert.ok($total_count.visible());
 | 
			
		||||
    assert.equal($total_count.hasClass("hide"), false);
 | 
			
		||||
 | 
			
		||||
    counts = {
 | 
			
		||||
        private_message_count: 0,
 | 
			
		||||
@@ -36,5 +36,5 @@ run_test("update_dom_with_unread_counts", () => {
 | 
			
		||||
 | 
			
		||||
    pm_list.set_count(counts.private_message_count);
 | 
			
		||||
    assert.equal($total_count.text(), "");
 | 
			
		||||
    assert.ok(!$total_count.visible());
 | 
			
		||||
    assert.equal($total_count.hasClass("hide"), true);
 | 
			
		||||
});
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user