mirror of https://github.com/zulip/zulip.git
topic-list-data: Increase max topics shown in left sidebar.
Incresase the max number of stream topics shown when not zoomed into the stream for more topics in the left sidebar to be a max of 8 unread conversations and 12 when there are unreads.
This commit is contained in:
parent
e1a2789de2
commit
95d48bc2ad
|
@ -8,8 +8,8 @@ import * as unread from "./unread";
|
|||
import * as user_topics from "./user_topics";
|
||||
import * as util from "./util";
|
||||
|
||||
const max_topics = 5;
|
||||
const max_topics_with_unread = 8;
|
||||
const max_topics = 8;
|
||||
const max_topics_with_unread = 12;
|
||||
|
||||
export function get_list_info(stream_id, zoomed) {
|
||||
let topics_selected = 0;
|
||||
|
|
|
@ -70,7 +70,7 @@ test("get_list_info w/real stream_topic_history", ({override}) => {
|
|||
message_id,
|
||||
});
|
||||
}
|
||||
for (const i of _.range(7)) {
|
||||
for (const i of _.range(10)) {
|
||||
let topic_name;
|
||||
// All odd topics are resolved.
|
||||
if (i % 2) {
|
||||
|
@ -84,21 +84,21 @@ test("get_list_info w/real stream_topic_history", ({override}) => {
|
|||
override(narrow_state, "topic", () => "topic 6");
|
||||
|
||||
list_info = get_list_info();
|
||||
assert.equal(list_info.items.length, 5);
|
||||
assert.equal(list_info.items.length, 8);
|
||||
assert.equal(list_info.more_topics_unreads, 0);
|
||||
assert.equal(list_info.more_topics_have_unread_mention_messages, false);
|
||||
assert.equal(list_info.num_possible_topics, 7);
|
||||
assert.equal(list_info.num_possible_topics, 10);
|
||||
|
||||
assert.deepEqual(list_info.items[0], {
|
||||
contains_unread_mention: false,
|
||||
is_active_topic: true,
|
||||
is_active_topic: false,
|
||||
is_muted: false,
|
||||
is_zero: true,
|
||||
topic_display_name: "topic 6",
|
||||
topic_name: "topic 6",
|
||||
topic_resolved_prefix: "",
|
||||
topic_display_name: "topic 9",
|
||||
topic_name: "✔ topic 9",
|
||||
topic_resolved_prefix: "✔ ",
|
||||
unread: 0,
|
||||
url: "#narrow/stream/556-general/topic/topic.206",
|
||||
url: "#narrow/stream/556-general/topic/.E2.9C.94.20topic.209",
|
||||
});
|
||||
|
||||
assert.deepEqual(list_info.items[1], {
|
||||
|
@ -106,22 +106,22 @@ test("get_list_info w/real stream_topic_history", ({override}) => {
|
|||
is_active_topic: false,
|
||||
is_muted: false,
|
||||
is_zero: true,
|
||||
topic_display_name: "topic 5",
|
||||
topic_name: "✔ topic 5",
|
||||
topic_resolved_prefix: "✔ ",
|
||||
topic_display_name: "topic 8",
|
||||
topic_name: "topic 8",
|
||||
topic_resolved_prefix: "",
|
||||
unread: 0,
|
||||
url: "#narrow/stream/556-general/topic/.E2.9C.94.20topic.205",
|
||||
url: "#narrow/stream/556-general/topic/topic.208",
|
||||
});
|
||||
// If we zoom in, our results based on topic filter.
|
||||
// If topic search input is empty, we show all 7 topics.
|
||||
// If topic search input is empty, we show all 10 topics.
|
||||
|
||||
const zoomed = true;
|
||||
override(topic_list, "get_topic_search_term", () => "");
|
||||
list_info = get_list_info(zoomed);
|
||||
assert.equal(list_info.items.length, 7);
|
||||
assert.equal(list_info.items.length, 10);
|
||||
assert.equal(list_info.more_topics_unreads, 0);
|
||||
assert.equal(list_info.more_topics_have_unread_mention_messages, false);
|
||||
assert.equal(list_info.num_possible_topics, 7);
|
||||
assert.equal(list_info.num_possible_topics, 10);
|
||||
|
||||
add_topic_message("After Brooklyn", 1008);
|
||||
add_topic_message("Catering", 1009);
|
||||
|
@ -138,7 +138,7 @@ test("get_list_info unreads", ({override}) => {
|
|||
let list_info;
|
||||
|
||||
let message_id = 0;
|
||||
for (let i = 14; i >= 0; i -= 1) {
|
||||
for (let i = 15; i >= 0; i -= 1) {
|
||||
stream_topic_history.add_message({
|
||||
stream_id: general.stream_id,
|
||||
message_id: (message_id += 1),
|
||||
|
@ -173,67 +173,105 @@ test("get_list_info unreads", ({override}) => {
|
|||
}
|
||||
|
||||
/*
|
||||
We have 15 topics, but we only show up
|
||||
to 8 topics, depending on how many have
|
||||
unread counts. We only show a max of 5
|
||||
We have 16 topics, but we only show up
|
||||
to 12 topics, depending on how many have
|
||||
unread counts. We only show a max of 8
|
||||
fully-read topics.
|
||||
|
||||
So first we'll get 7 topics, where 2 are
|
||||
So first we'll get 10 topics, where 2 are
|
||||
unread.
|
||||
*/
|
||||
add_unreads("topic 8", 8);
|
||||
add_unreads("topic 9", 9);
|
||||
add_unreads("topic 14", 1);
|
||||
add_unreads("topic 13", 1);
|
||||
|
||||
/*
|
||||
We added 9 unread messages in 'topic 9',
|
||||
We added 1 unread message in 'topic 14',
|
||||
but now we would add a unread message
|
||||
with `mention` for user, to test
|
||||
`more_topics_have_unread_mention_messages`.
|
||||
*/
|
||||
add_unreads_with_mention("topic 9", 1);
|
||||
add_unreads_with_mention("topic 14", 1);
|
||||
|
||||
list_info = get_list_info();
|
||||
assert.equal(list_info.items.length, 7);
|
||||
assert.equal(list_info.items.length, 10);
|
||||
assert.equal(list_info.more_topics_unreads, 0);
|
||||
assert.equal(list_info.more_topics_have_unread_mention_messages, false);
|
||||
assert.equal(list_info.num_possible_topics, 15);
|
||||
assert.equal(list_info.num_possible_topics, 16);
|
||||
|
||||
assert.deepEqual(
|
||||
list_info.items.map((li) => li.topic_name),
|
||||
["topic 0", "topic 1", "topic 2", "topic 3", "topic 4", "topic 8", "topic 9"],
|
||||
[
|
||||
"topic 0",
|
||||
"topic 1",
|
||||
"topic 2",
|
||||
"topic 3",
|
||||
"topic 4",
|
||||
"topic 5",
|
||||
"topic 6",
|
||||
"topic 7",
|
||||
"topic 13",
|
||||
"topic 14",
|
||||
],
|
||||
);
|
||||
|
||||
add_unreads("topic 6", 6);
|
||||
add_unreads("topic 7", 7);
|
||||
add_unreads("topic 12", 1);
|
||||
add_unreads("topic 11", 1);
|
||||
add_unreads("topic 10", 1);
|
||||
|
||||
list_info = get_list_info();
|
||||
assert.equal(list_info.items.length, 8);
|
||||
assert.equal(list_info.more_topics_unreads, 10);
|
||||
assert.equal(list_info.items.length, 12);
|
||||
assert.equal(list_info.more_topics_unreads, 2);
|
||||
assert.equal(list_info.more_topics_have_unread_mention_messages, true);
|
||||
assert.equal(list_info.num_possible_topics, 15);
|
||||
assert.equal(list_info.num_possible_topics, 16);
|
||||
|
||||
assert.deepEqual(
|
||||
list_info.items.map((li) => li.topic_name),
|
||||
["topic 0", "topic 1", "topic 2", "topic 3", "topic 4", "topic 6", "topic 7", "topic 8"],
|
||||
[
|
||||
"topic 0",
|
||||
"topic 1",
|
||||
"topic 2",
|
||||
"topic 3",
|
||||
"topic 4",
|
||||
"topic 5",
|
||||
"topic 6",
|
||||
"topic 7",
|
||||
"topic 10",
|
||||
"topic 11",
|
||||
"topic 12",
|
||||
"topic 13",
|
||||
],
|
||||
);
|
||||
|
||||
add_unreads("topic 4", 4);
|
||||
add_unreads("topic 5", 5);
|
||||
add_unreads("topic 13", 13);
|
||||
add_unreads("topic 9", 1);
|
||||
add_unreads("topic 8", 1);
|
||||
|
||||
add_unreads("topic 4", 1);
|
||||
override(user_topics, "is_topic_muted", (stream_id, topic_name) => {
|
||||
assert.equal(stream_id, general.stream_id);
|
||||
return topic_name === "topic 4";
|
||||
});
|
||||
|
||||
list_info = get_list_info();
|
||||
assert.equal(list_info.items.length, 8);
|
||||
assert.equal(list_info.more_topics_unreads, 10 + 13);
|
||||
assert.equal(list_info.items.length, 12);
|
||||
assert.equal(list_info.more_topics_unreads, 3);
|
||||
assert.equal(list_info.more_topics_have_unread_mention_messages, true);
|
||||
assert.equal(list_info.num_possible_topics, 15);
|
||||
assert.equal(list_info.num_possible_topics, 16);
|
||||
|
||||
assert.deepEqual(
|
||||
list_info.items.map((li) => li.topic_name),
|
||||
["topic 0", "topic 1", "topic 2", "topic 3", "topic 5", "topic 6", "topic 7", "topic 8"],
|
||||
[
|
||||
"topic 0",
|
||||
"topic 1",
|
||||
"topic 2",
|
||||
"topic 3",
|
||||
"topic 5",
|
||||
"topic 6",
|
||||
"topic 7",
|
||||
"topic 8",
|
||||
"topic 9",
|
||||
"topic 10",
|
||||
"topic 11",
|
||||
"topic 12",
|
||||
],
|
||||
);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue