recent view data: Rename get to get_topics.

This commit is contained in:
evykassirer 2023-10-29 19:04:00 -07:00 committed by Tim Abbott
parent f786b10403
commit 83e0f8bd33
3 changed files with 14 additions and 14 deletions

View File

@ -58,7 +58,7 @@ function get_sorted_topics(): Map<string | undefined, TopicData> {
return new Map([...topics.entries()].sort((a, b) => b[1].last_msg_id - a[1].last_msg_id));
}
export function get(): Map<string | undefined, TopicData> {
export function get_topics(): Map<string | undefined, TopicData> {
return get_sorted_topics();
}

View File

@ -941,7 +941,7 @@ export function complete_rerender() {
}
// Show topics list
const mapped_topic_values = [...recent_view_data.get().values()];
const mapped_topic_values = [...recent_view_data.get_topics().values()];
if (topics_widget) {
topics_widget.replace_list_data(mapped_topic_values);

View File

@ -952,7 +952,7 @@ test("basic assertions", ({mock_template, override_rewire}) => {
rt.set_default_focus();
rt.set_filter("all");
rt.process_messages(messages);
let all_topics = rt_data.get();
let all_topics = rt_data.get_topics();
// update a message
generate_topic_data([[1, "topic-7", 1, all_visibility_policies.INHERIT]]);
@ -1014,7 +1014,7 @@ test("basic assertions", ({mock_template, override_rewire}) => {
type: "private",
to_user_ids: "6,7,8",
});
all_topics = rt_data.get();
all_topics = rt_data.get_topics();
assert.equal(all_topics.size, 12);
assert.equal(
[...all_topics.keys()].toString(),
@ -1039,7 +1039,7 @@ test("basic assertions", ({mock_template, override_rewire}) => {
type: "stream",
});
all_topics = rt_data.get();
all_topics = rt_data.get_topics();
assert.equal(
[...all_topics.keys()].toString(),
"1:topic-3,6:topic-12,6:topic-11,6:topic-8,4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-2,1:topic-1,6,7,8",
@ -1056,7 +1056,7 @@ test("basic assertions", ({mock_template, override_rewire}) => {
type: "stream",
});
all_topics = rt_data.get();
all_topics = rt_data.get_topics();
assert.equal(
[...all_topics.keys()].toString(),
"1:topic-7,1:topic-3,6:topic-12,6:topic-11,6:topic-8,4:topic-10,1:topic-6,1:topic-5,1:topic-4,1:topic-2,1:topic-1,6,7,8",
@ -1134,14 +1134,14 @@ test("test_delete_messages", ({override}) => {
let reduced_msgs = messages.slice(1);
override(all_messages_data, "all_messages", () => reduced_msgs);
let all_topics = rt_data.get();
let all_topics = rt_data.get_topics();
assert.equal(
[...all_topics.keys()].toString(),
"6:topic-12,6:topic-11,6:topic-8,4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-3,1:topic-2,1:topic-1",
);
rt.update_topics_of_deleted_message_ids([messages[0].id]);
all_topics = rt_data.get();
all_topics = rt_data.get_topics();
assert.equal(
[...all_topics.keys()].toString(),
"6:topic-12,6:topic-11,6:topic-8,4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-3,1:topic-2",
@ -1152,7 +1152,7 @@ test("test_delete_messages", ({override}) => {
rt.update_topics_of_deleted_message_ids([messages[1].id, messages[2].id]);
all_topics = rt_data.get();
all_topics = rt_data.get_topics();
assert.equal(
[...all_topics.keys()].toString(),
"6:topic-12,6:topic-11,6:topic-8,4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-3",
@ -1172,7 +1172,7 @@ test("test_topic_edit", ({override}) => {
rt.set_filter("all");
rt.process_messages(messages);
let all_topics = rt_data.get();
let all_topics = rt_data.get_topics();
assert.equal(
[...all_topics.keys()].toString(),
"6:topic-12,6:topic-11,6:topic-8,4:topic-10,1:topic-7,1:topic-6,1:topic-5,1:topic-4,1:topic-3,1:topic-2,1:topic-1",
@ -1186,7 +1186,7 @@ test("test_topic_edit", ({override}) => {
messages[7].topic = topic8;
messages[8].topic = topic8;
rt.process_topic_edit(stream1, topic6, topic8);
all_topics = rt_data.get();
all_topics = rt_data.get_topics();
verify_topic_data(all_topics, stream1, topic8, messages[8].id, true);
assert.equal(all_topics.get(get_topic_key(stream1, topic6)), undefined);
@ -1197,7 +1197,7 @@ test("test_topic_edit", ({override}) => {
messages[0].stream_id = stream2;
rt.process_topic_edit(stream1, topic1, topic1, stream2);
all_topics = rt_data.get();
all_topics = rt_data.get_topics();
assert.equal(all_topics.get(get_topic_key(stream1, topic1)), undefined);
verify_topic_data(all_topics, stream2, topic1, messages[0].id, true);
@ -1209,7 +1209,7 @@ test("test_topic_edit", ({override}) => {
messages[0].stream_id = stream3;
messages[0].topic = topic9;
rt.process_topic_edit(stream2, topic1, topic9, stream3);
all_topics = rt_data.get();
all_topics = rt_data.get_topics();
assert.equal(all_topics.get(get_topic_key(stream2, topic1)), undefined);
verify_topic_data(all_topics, stream3, topic9, messages[0].id, true);
@ -1218,7 +1218,7 @@ test("test_topic_edit", ({override}) => {
messages[0].stream_id = stream5;
messages[0].topic = topic8;
rt.process_topic_edit(stream3, topic9, topic8, stream5);
all_topics = rt_data.get();
all_topics = rt_data.get_topics();
assert.equal(rt.filters_should_hide_topic(all_topics.get("5:topic-8")), true);
});