Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

filter: Consider `/near/` views as conversation views.

Aman Agrawal3ce07c980665
diff --git a/web/src/compose_notifications.ts b/web/src/compose_notifications.ts
index 5bcc87ebd6b..68b49532d43 100644
--- a/web/src/compose_notifications.ts
+++ b/web/src/compose_notifications.ts
@@ -178,10 +178,7 @@ export function should_jump_to_sent_message_conversation(message: Message): bool
const current_filter = narrow_state.filter();
const is_conversation_view =
- current_filter === undefined
- ? false
- : current_filter.is_conversation_view() ||
- current_filter.is_conversation_view_with_near();
+ current_filter === undefined ? false : current_filter.is_conversation_view();
const $row = message_lists.current.get_row(message.id);
if (is_conversation_view && $row.length > 0) {
// If our message is in the current conversation view, we do
diff --git a/web/src/compose_setup.ts b/web/src/compose_setup.ts
index 01d17f444d1..8c4dc120342 100644
--- a/web/src/compose_setup.ts
+++ b/web/src/compose_setup.ts
@@ -230,8 +230,7 @@ export function initialize(): void {
const stream_id_string = stream_id.toString();
if (
current_filter &&
- (current_filter.is_conversation_view() ||
- current_filter.is_conversation_view_with_near()) &&
+ current_filter.is_conversation_view() &&
current_filter.has_topic(stream_id_string, topic_name)
) {
message_view.show(
diff --git a/web/src/filter.ts b/web/src/filter.ts
index b1228b92c68..e53772c4565 100644
--- a/web/src/filter.ts
+++ b/web/src/filter.ts
@@ -1845,8 +1845,10 @@ export class Filter {
is_conversation_view(): 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, ["dm", "near"]) ||
_.isEqual(term_types, ["dm", "with"]) ||
_.isEqual(term_types, ["dm"])
) {
diff --git a/web/src/message_lists.ts b/web/src/message_lists.ts
index 9119268048d..60db5f06468 100644
--- a/web/src/message_lists.ts
+++ b/web/src/message_lists.ts
@@ -57,10 +57,7 @@ export function update_current_message_list(msg_list: MessageList | undefined):
current.view.$list.addClass("focused-message-list");
}
- if (
- current?.data.filter.is_conversation_view() ||
- current?.data.filter.is_conversation_view_with_near()
- ) {
+ if (current?.data.filter.is_conversation_view()) {
$(".focused-message-list").addClass("is-conversation-view");
} else {
$(".focused-message-list").removeClass("is-conversation-view");
diff --git a/web/src/message_view.ts b/web/src/message_view.ts
index 3a1340df776..4395bd6e3ad 100644
--- a/web/src/message_view.ts
+++ b/web/src/message_view.ts
@@ -858,7 +858,8 @@ export let show = (raw_terms: NarrowTerm[], show_opts: ShowMessageViewOpts): voi
);
if (
id_info.first_unread_msg_id_pending_server_verification &&
- filter.is_conversation_view()
+ filter.is_conversation_view() &&
+ !filter.is_conversation_view_with_near()
) {
const params = message_fetch.get_parameters_for_message_fetch_api({
anchor: "first_unread",
@@ -909,9 +910,8 @@ export let show = (raw_terms: NarrowTerm[], show_opts: ShowMessageViewOpts): voi
},
];
assert(msg_list.data.filter.is_conversation_view());
- // Using both /with/ and /near/ operators in a single view doesn't
- // make sense, and checks like is_conversation_view_with_near do not
- // handle that combination correctly.
+ // We remove /with/ because using both /with/ and /near/
+ // operators in a single view doesn't make sense.
terms = terms.filter((term) => term.operator !== "with");
// We are not navigating user to a different place but want to
// keep user at the same place but avoid marking messages as read.
diff --git a/web/src/scheduled_messages_feed_ui.ts b/web/src/scheduled_messages_feed_ui.ts
index 0bd041f01a6..9d8316a552f 100644
--- a/web/src/scheduled_messages_feed_ui.ts
+++ b/web/src/scheduled_messages_feed_ui.ts
@@ -10,10 +10,7 @@ import * as util from "./util.ts";
function get_scheduled_messages_matching_narrow(): ScheduledMessage[] {
const scheduled_messages_list = scheduled_messages.get_all_scheduled_messages();
const filter = narrow_state.filter();
- const is_conversation_view =
- filter === undefined
- ? false
- : filter.is_conversation_view() || filter.is_conversation_view_with_near();
+ const is_conversation_view = filter === undefined ? false : filter.is_conversation_view();
const current_view_type = narrow_state.narrowed_to_pms() ? "private" : "stream";
if (!is_conversation_view) {
diff --git a/web/tests/filter.test.cjs b/web/tests/filter.test.cjs
index 40ed604b7a7..79919ac4171 100644
--- a/web/tests/filter.test.cjs
+++ b/web/tests/filter.test.cjs
@@ -256,7 +256,7 @@ test("basics", () => {
assert.ok(!filter.is_personal_filter());
assert.ok(filter.can_bucket_by("channel"));
assert.ok(filter.can_bucket_by("channel", "topic"));
- assert.ok(!filter.is_conversation_view());
+ assert.ok(filter.is_conversation_view());
assert.ok(!filter.is_channel_view());
assert.ok(filter.is_conversation_view_with_near());
assert.ok(!filter.may_contain_multiple_conversations());
@@ -473,7 +473,7 @@ test("basics", () => {
assert.ok(!filter.has_operator("search"));
assert.ok(filter.can_apply_locally());
assert.ok(!filter.is_personal_filter());
- assert.ok(!filter.is_conversation_view());
+ assert.ok(filter.is_conversation_view());
assert.ok(filter.is_conversation_view_with_near());
assert.ok(!filter.may_contain_multiple_conversations());
assert.ok(!filter.is_channel_view());