unread: Rename function name for clarity.

Renamed num_unread_for_person to num_unread_for_user_ids_string.
This commit is contained in:
Aman Agrawal 2022-10-22 05:15:44 +00:00 committed by Tim Abbott
parent 284c86212c
commit eb45b8ab70
8 changed files with 25 additions and 25 deletions

View File

@ -109,8 +109,8 @@ function get_list_info(zoomed) {
test("get_conversations", ({override}) => {
pm_conversations.recent.insert([alice.user_id, bob.user_id], 1);
pm_conversations.recent.insert([me.user_id], 2);
let num_unread_for_person = 1;
override(unread, "num_unread_for_person", () => num_unread_for_person);
let num_unread_for_user_ids_string = 1;
override(unread, "num_unread_for_user_ids_string", () => num_unread_for_user_ids_string);
assert.equal(narrow_state.filter(), undefined);
@ -144,7 +144,7 @@ test("get_conversations", ({override}) => {
let pm_data = pm_list_data.get_conversations();
assert.deepEqual(pm_data, expected_data);
num_unread_for_person = 0;
num_unread_for_user_ids_string = 0;
pm_data = pm_list_data.get_conversations();
expected_data[0].unread = 0;
@ -161,7 +161,7 @@ test("get_conversations bot", ({override}) => {
pm_conversations.recent.insert([alice.user_id, bob.user_id], 1);
pm_conversations.recent.insert([bot_test.user_id], 2);
override(unread, "num_unread_for_person", () => 1);
override(unread, "num_unread_for_user_ids_string", () => 1);
assert.equal(narrow_state.filter(), undefined);
@ -258,8 +258,8 @@ test("get_list_info", ({override}) => {
assert.equal(pm_list_data.get_active_user_ids_string(), undefined);
// Mock to arrange that each user has exactly 1 unread.
const num_unread_for_person = 1;
override(unread, "num_unread_for_person", () => num_unread_for_person);
const num_unread_for_user_ids_string = 1;
override(unread, "num_unread_for_user_ids_string", () => num_unread_for_user_ids_string);
// Initially, we append 2 conversations and check for the
// `conversations_to_be_shown` returned in list_info.
@ -401,7 +401,7 @@ test("get_list_info", ({override}) => {
);
// We now test some no unreads cases.
override(unread, "num_unread_for_person", () => 0);
override(unread, "num_unread_for_user_ids_string", () => 0);
pm_conversations.clear_for_testing();
pm_conversations.recent.insert([alice.user_id], 1);
pm_conversations.recent.insert([bob.user_id], 2);

View File

@ -123,7 +123,7 @@ run_test("topics", ({override}) => {
run_test("get_next_unread_pm_string", ({override}) => {
pm_conversations.recent.get_strings = () => ["1", "read", "2,3", "4", "unk"];
override(unread, "num_unread_for_person", (user_ids_string) => {
override(unread, "num_unread_for_user_ids_string", (user_ids_string) => {
if (user_ids_string === "unk") {
return undefined;
}
@ -143,7 +143,7 @@ run_test("get_next_unread_pm_string", ({override}) => {
assert.equal(tg.get_next_unread_pm_string("read"), "2,3");
assert.equal(tg.get_next_unread_pm_string("2,3"), "4");
override(unread, "num_unread_for_person", () => 0);
override(unread, "num_unread_for_user_ids_string", () => 0);
assert.equal(tg.get_next_unread_pm_string("2,3"), undefined);
});

View File

@ -420,8 +420,8 @@ test("private_messages", () => {
};
people.add_active_user(bob);
assert.equal(unread.num_unread_for_person(alice.user_id.toString()), 0);
assert.equal(unread.num_unread_for_person(bob.user_id.toString()), 0);
assert.equal(unread.num_unread_for_user_ids_string(alice.user_id.toString()), 0);
assert.equal(unread.num_unread_for_user_ids_string(bob.user_id.toString()), 0);
assert.deepEqual(unread.get_msg_ids_for_user_ids_string(alice.user_id.toString()), []);
assert.deepEqual(unread.get_msg_ids_for_user_ids_string(bob.user_id.toString()), []);
assert.deepEqual(unread.get_msg_ids_for_user_ids_string(), []);
@ -439,9 +439,9 @@ test("private_messages", () => {
flags: ["read"],
};
unread.process_loaded_messages([message, read_message]);
assert.equal(unread.num_unread_for_person(alice.user_id.toString()), 1);
assert.equal(unread.num_unread_for_user_ids_string(alice.user_id.toString()), 1);
assert.equal(unread.num_unread_for_person(""), 0);
assert.equal(unread.num_unread_for_user_ids_string(""), 0);
assert.deepEqual(unread.get_msg_ids_for_user_ids_string(alice.user_id.toString()), [
message.id,
@ -451,8 +451,8 @@ test("private_messages", () => {
assert.deepEqual(unread.get_all_msg_ids(), [message.id]);
unread.mark_as_read(message.id);
assert.equal(unread.num_unread_for_person(alice.user_id.toString()), 0);
assert.equal(unread.num_unread_for_person(""), 0);
assert.equal(unread.num_unread_for_user_ids_string(alice.user_id.toString()), 0);
assert.equal(unread.num_unread_for_user_ids_string(""), 0);
assert.deepEqual(unread.get_msg_ids_for_user_ids_string(alice.user_id.toString()), []);
assert.deepEqual(unread.get_msg_ids_for_user_ids_string(bob.user_id.toString()), []);
assert.deepEqual(unread.get_msg_ids_for_private(), []);
@ -725,9 +725,9 @@ test("server_counts", () => {
unread.initialize();
assert.equal(unread.num_unread_for_person("101"), 6);
assert.equal(unread.num_unread_for_person("4,6,101"), 2);
assert.equal(unread.num_unread_for_person("30"), 0);
assert.equal(unread.num_unread_for_user_ids_string("101"), 6);
assert.equal(unread.num_unread_for_user_ids_string("4,6,101"), 2);
assert.equal(unread.num_unread_for_user_ids_string("30"), 0);
assert.equal(unread.num_unread_for_topic(0, "bogus"), 0);
assert.equal(unread.num_unread_for_topic(1, "bogus"), 0);
@ -742,7 +742,7 @@ test("server_counts", () => {
assert.equal(unread.num_unread_for_topic(1, "test"), 2);
unread.mark_as_read(34);
assert.equal(unread.num_unread_for_person("4,6,101"), 1);
assert.equal(unread.num_unread_for_user_ids_string("4,6,101"), 1);
});
test("empty_cases", () => {

View File

@ -91,7 +91,7 @@ export function sort_users(user_ids) {
}
function get_num_unread(user_id) {
return unread.num_unread_for_person(user_id.toString());
return unread.num_unread_for_user_ids_string(user_id.toString());
}
export function user_last_seen_time_status(user_id) {

View File

@ -40,7 +40,7 @@ export function get_conversations() {
const reply_to = people.user_ids_string_to_emails_string(user_ids_string);
const recipients_string = people.get_recipients(user_ids_string);
const num_unread = unread.num_unread_for_person(user_ids_string);
const num_unread = unread.num_unread_for_user_ids_string(user_ids_string);
const is_group = user_ids_string.includes(",");
const is_active = user_ids_string === active_user_ids_string;

View File

@ -302,7 +302,7 @@ export function process_messages(messages) {
function message_to_conversation_unread_count(msg) {
if (msg.type === "private") {
return unread.num_unread_for_person(msg.to_user_ids);
return unread.num_unread_for_user_ids_string(msg.to_user_ids);
}
return unread.num_unread_for_topic(msg.stream_id, msg.topic);
}

View File

@ -84,13 +84,13 @@ export function get_next_unread_pm_string(curr_pm) {
const curr_pm_index = my_pm_strings.indexOf(curr_pm); // -1 if not found
for (let i = curr_pm_index + 1; i < my_pm_strings.length; i += 1) {
if (unread.num_unread_for_person(my_pm_strings[i]) > 0) {
if (unread.num_unread_for_user_ids_string(my_pm_strings[i]) > 0) {
return my_pm_strings[i];
}
}
for (let i = 0; i < curr_pm_index; i += 1) {
if (unread.num_unread_for_person(my_pm_strings[i]) > 0) {
if (unread.num_unread_for_user_ids_string(my_pm_strings[i]) > 0) {
return my_pm_strings[i];
}
}

View File

@ -716,7 +716,7 @@ export function get_topics_with_unread_mentions(stream_id) {
return unread_topic_counter.get_topics_with_unread_mentions(stream_id);
}
export function num_unread_for_person(user_ids_string) {
export function num_unread_for_user_ids_string(user_ids_string) {
return unread_pm_counter.num_unread(user_ids_string);
}