mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-03 21:43:21 +00:00 
			
		
		
		
	unread: Use some clearer variable names.
This commit is contained in:
		@@ -453,7 +453,7 @@ function reset_data() {
 | 
			
		||||
    let has_topics_post_filter = false;
 | 
			
		||||
    if (unread_stream_msg_count) {
 | 
			
		||||
        for (const [stream_id, topic_dict] of unread_streams_dict) {
 | 
			
		||||
            const stream_unread = unread.num_unread_for_stream(stream_id);
 | 
			
		||||
            const stream_unread = unread.unread_count_info_for_stream(stream_id);
 | 
			
		||||
            const stream_unread_count = stream_unread.unmuted_count + stream_unread.muted_count;
 | 
			
		||||
            const stream_key = get_stream_key(stream_id);
 | 
			
		||||
            if (stream_unread_count > 0) {
 | 
			
		||||
@@ -1019,7 +1019,7 @@ export function update() {
 | 
			
		||||
 | 
			
		||||
    let has_topics_post_filter = false;
 | 
			
		||||
    for (const [stream_id, topic_dict] of unread_streams_dict) {
 | 
			
		||||
        const stream_unread = unread.num_unread_for_stream(stream_id);
 | 
			
		||||
        const stream_unread = unread.unread_count_info_for_stream(stream_id);
 | 
			
		||||
        const stream_unread_count = stream_unread.unmuted_count + stream_unread.muted_count;
 | 
			
		||||
        const stream_key = get_stream_key(stream_id);
 | 
			
		||||
        let stream_post_filter_unread_count = 0;
 | 
			
		||||
 
 | 
			
		||||
@@ -469,7 +469,7 @@ class StreamSidebarRow {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    update_unread_count() {
 | 
			
		||||
        const count = unread.num_unread_for_stream(this.sub.stream_id);
 | 
			
		||||
        const count = unread.unread_count_info_for_stream(this.sub.stream_id);
 | 
			
		||||
        const stream_has_any_unread_mention_messages = unread.stream_has_any_unread_mentions(
 | 
			
		||||
            this.sub.stream_id,
 | 
			
		||||
        );
 | 
			
		||||
 
 | 
			
		||||
@@ -307,7 +307,7 @@ class UnreadTopicCounter {
 | 
			
		||||
                // get_stream_count calculates both the number of
 | 
			
		||||
                // unmuted unread as well as the number of muted
 | 
			
		||||
                // unreads.
 | 
			
		||||
                res.stream_count.set(stream_id, this.get_stream_count(stream_id));
 | 
			
		||||
                res.stream_count.set(stream_id, this.get_stream_count_info(stream_id));
 | 
			
		||||
                res.stream_unread_messages += res.stream_count.get(stream_id).unmuted_count;
 | 
			
		||||
                res.followed_topic_unread_messages +=
 | 
			
		||||
                    res.stream_count.get(stream_id).followed_count;
 | 
			
		||||
@@ -358,7 +358,7 @@ class UnreadTopicCounter {
 | 
			
		||||
        return result;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    get_stream_count(stream_id) {
 | 
			
		||||
    get_stream_count_info(stream_id) {
 | 
			
		||||
        const per_stream_bucketer = this.bucketer.get_bucket(stream_id);
 | 
			
		||||
 | 
			
		||||
        if (!per_stream_bucketer) {
 | 
			
		||||
@@ -896,8 +896,8 @@ export function get_notifiable_count() {
 | 
			
		||||
    return calculate_notifiable_count(res);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function num_unread_for_stream(stream_id) {
 | 
			
		||||
    return unread_topic_counter.get_stream_count(stream_id);
 | 
			
		||||
export function unread_count_info_for_stream(stream_id) {
 | 
			
		||||
    return unread_topic_counter.get_stream_count_info(stream_id);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function num_unread_for_topic(stream_id, topic_name) {
 | 
			
		||||
 
 | 
			
		||||
@@ -13,7 +13,7 @@ page_params.is_admin = false;
 | 
			
		||||
page_params.realm_users = [];
 | 
			
		||||
 | 
			
		||||
// We use this with override.
 | 
			
		||||
let num_unread_for_stream;
 | 
			
		||||
let unread_unmuted_count;
 | 
			
		||||
let stream_has_any_unread_mentions;
 | 
			
		||||
 | 
			
		||||
mock_esm("../src/narrow_state", {
 | 
			
		||||
@@ -25,8 +25,8 @@ const scroll_util = mock_esm("../src/scroll_util", {
 | 
			
		||||
    get_scroll_element: ($element) => $element,
 | 
			
		||||
});
 | 
			
		||||
mock_esm("../src/unread", {
 | 
			
		||||
    num_unread_for_stream: () => ({
 | 
			
		||||
        unmuted_count: num_unread_for_stream,
 | 
			
		||||
    unread_count_info_for_stream: () => ({
 | 
			
		||||
        unmuted_count: unread_unmuted_count,
 | 
			
		||||
        stream_is_muted: false,
 | 
			
		||||
        muted_count: 0,
 | 
			
		||||
    }),
 | 
			
		||||
@@ -75,7 +75,7 @@ function create_devel_sidebar_row({mock_template}) {
 | 
			
		||||
        return "<devel-sidebar-row-stub>";
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    num_unread_for_stream = 42;
 | 
			
		||||
    unread_unmuted_count = 42;
 | 
			
		||||
    stream_has_any_unread_mentions = false;
 | 
			
		||||
    stream_list.create_sidebar_row(devel);
 | 
			
		||||
    assert.equal($devel_count.text(), "42");
 | 
			
		||||
@@ -98,7 +98,7 @@ function create_social_sidebar_row({mock_template}) {
 | 
			
		||||
        return "<social-sidebar-row-stub>";
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    num_unread_for_stream = 99;
 | 
			
		||||
    unread_unmuted_count = 99;
 | 
			
		||||
    stream_has_any_unread_mentions = true;
 | 
			
		||||
    stream_list.create_sidebar_row(social);
 | 
			
		||||
    assert.equal($social_count.text(), "99");
 | 
			
		||||
 
 | 
			
		||||
@@ -239,7 +239,7 @@ test("muting", () => {
 | 
			
		||||
    let counts = unread.get_counts();
 | 
			
		||||
    assert.equal(counts.stream_count.get(stream_id).unmuted_count, 1);
 | 
			
		||||
    assert.equal(counts.home_unread_messages, 1);
 | 
			
		||||
    assert.equal(unread.num_unread_for_stream(stream_id).unmuted_count, 1);
 | 
			
		||||
    assert.equal(unread.unread_count_info_for_stream(stream_id).unmuted_count, 1);
 | 
			
		||||
    assert.deepEqual(unread.get_msg_ids_for_stream(stream_id), [message.id]);
 | 
			
		||||
    test_notifiable_count(counts.home_unread_messages, 0);
 | 
			
		||||
 | 
			
		||||
@@ -251,14 +251,14 @@ test("muting", () => {
 | 
			
		||||
    counts = unread.get_counts();
 | 
			
		||||
    assert.equal(counts.stream_count.get(stream_id).unmuted_count, 0);
 | 
			
		||||
    assert.equal(counts.home_unread_messages, 0);
 | 
			
		||||
    assert.equal(unread.num_unread_for_stream(stream_id).unmuted_count, 0);
 | 
			
		||||
    assert.equal(unread.unread_count_info_for_stream(stream_id).unmuted_count, 0);
 | 
			
		||||
    assert.deepEqual(unread.get_msg_ids_for_stream(stream_id), []);
 | 
			
		||||
    test_notifiable_count(counts.home_unread_messages, 0);
 | 
			
		||||
 | 
			
		||||
    // we still find the message id here (muting is ignored)
 | 
			
		||||
    assert.deepEqual(unread.get_all_msg_ids(), [message.id]);
 | 
			
		||||
 | 
			
		||||
    assert.equal(unread.num_unread_for_stream(unknown_stream_id), 0);
 | 
			
		||||
    assert.equal(unread.unread_count_info_for_stream(unknown_stream_id), 0);
 | 
			
		||||
});
 | 
			
		||||
 | 
			
		||||
test("num_unread_for_topic", () => {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user