mirror of https://github.com/zulip/zulip.git
filter: Add function to check if we can show the next unread button.
These function will be used when we add `Next unread conversation` button below message list.
This commit is contained in:
parent
0fb63eeddf
commit
ea4e48afa7
|
@ -1627,6 +1627,32 @@ export class Filter {
|
|||
});
|
||||
}
|
||||
|
||||
can_show_next_unread_topic_conversation_button(): boolean {
|
||||
const term_types = this.sorted_term_types();
|
||||
if (
|
||||
_.isEqual(term_types, ["channel", "topic", "near"]) ||
|
||||
_.isEqual(term_types, ["channel", "topic", "with"]) ||
|
||||
_.isEqual(term_types, ["channel", "topic"]) ||
|
||||
_.isEqual(term_types, ["channel"])
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
can_show_next_unread_dm_conversation_button(): boolean {
|
||||
const term_types = this.sorted_term_types();
|
||||
if (
|
||||
_.isEqual(term_types, ["dm", "near"]) ||
|
||||
_.isEqual(term_types, ["dm", "with"]) ||
|
||||
_.isEqual(term_types, ["dm"]) ||
|
||||
_.isEqual(term_types, ["is-dm"])
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
is_conversation_view(): boolean {
|
||||
const term_types = this.sorted_term_types();
|
||||
if (
|
||||
|
|
|
@ -128,6 +128,8 @@ test("basics", () => {
|
|||
assert.ok(filter.can_apply_locally());
|
||||
assert.ok(!filter.is_personal_filter());
|
||||
assert.ok(!filter.is_conversation_view());
|
||||
assert.ok(!filter.can_show_next_unread_topic_conversation_button());
|
||||
assert.ok(!filter.can_show_next_unread_dm_conversation_button());
|
||||
|
||||
assert.ok(filter.can_bucket_by("channel"));
|
||||
assert.ok(filter.can_bucket_by("channel", "topic"));
|
||||
|
@ -139,6 +141,8 @@ test("basics", () => {
|
|||
assert.deepEqual(filter.operands("channel"), [foo_stream_id.toString()]);
|
||||
assert.ok(filter.includes_full_stream_history());
|
||||
assert.ok(filter.can_apply_locally());
|
||||
assert.ok(filter.can_show_next_unread_topic_conversation_button());
|
||||
assert.ok(!filter.can_show_next_unread_dm_conversation_button());
|
||||
|
||||
terms = [
|
||||
{operator: "channel", operand: foo_stream_id.toString()},
|
||||
|
@ -201,6 +205,8 @@ test("basics", () => {
|
|||
assert.ok(filter.can_bucket_by("channel", "topic"));
|
||||
assert.ok(!filter.is_conversation_view());
|
||||
assert.ok(filter.is_conversation_view_with_near());
|
||||
assert.ok(filter.can_show_next_unread_topic_conversation_button());
|
||||
assert.ok(!filter.can_show_next_unread_dm_conversation_button());
|
||||
|
||||
// If our only channel operator is negated, then for all intents and purposes,
|
||||
// we don't consider ourselves to have a channel operator, because we don't
|
||||
|
@ -226,6 +232,8 @@ test("basics", () => {
|
|||
assert.ok(!filter.supports_collapsing_recipients());
|
||||
assert.ok(!filter.is_personal_filter());
|
||||
assert.ok(!filter.is_conversation_view());
|
||||
assert.ok(!filter.can_show_next_unread_topic_conversation_button());
|
||||
assert.ok(!filter.can_show_next_unread_dm_conversation_button());
|
||||
|
||||
// Similar logic applies to negated "has" searches.
|
||||
terms = [{operator: "has", operand: "images", negated: true}];
|
||||
|
@ -278,12 +286,16 @@ test("basics", () => {
|
|||
assert.ok(filter.can_apply_locally());
|
||||
assert.ok(!filter.is_personal_filter());
|
||||
assert.ok(!filter.is_conversation_view());
|
||||
assert.ok(!filter.can_show_next_unread_topic_conversation_button());
|
||||
assert.ok(filter.can_show_next_unread_dm_conversation_button());
|
||||
|
||||
// "is:private" was renamed to "is:dm"
|
||||
terms = [{operator: "is", operand: "private"}];
|
||||
filter = new Filter(terms);
|
||||
assert.ok(filter.has_operand("is", "dm"));
|
||||
assert.ok(!filter.has_operand("is", "private"));
|
||||
assert.ok(!filter.can_show_next_unread_topic_conversation_button());
|
||||
assert.ok(filter.can_show_next_unread_dm_conversation_button());
|
||||
|
||||
terms = [{operator: "is", operand: "mentioned"}];
|
||||
filter = new Filter(terms);
|
||||
|
@ -294,6 +306,8 @@ test("basics", () => {
|
|||
assert.ok(filter.can_apply_locally());
|
||||
assert.ok(filter.is_personal_filter());
|
||||
assert.ok(!filter.is_conversation_view());
|
||||
assert.ok(!filter.can_show_next_unread_topic_conversation_button());
|
||||
assert.ok(!filter.can_show_next_unread_dm_conversation_button());
|
||||
|
||||
terms = [{operator: "is", operand: "starred"}];
|
||||
filter = new Filter(terms);
|
||||
|
|
Loading…
Reference in New Issue