scheduled_message_feed_ui: Show the scheduled indicator in near view.

Earlier, when a user was in /near/ topic or dm view, the scheduled
message indicator was missing in the conversation.

This commit fixes the incorrect behavior.
This commit is contained in:
Prakhar Pratyush 2024-06-07 13:43:36 +05:30 committed by Tim Abbott
parent 1c5007461a
commit bb4d62ffa6
3 changed files with 35 additions and 1 deletions

View File

@ -1303,6 +1303,17 @@ export class Filter {
return false; return false;
} }
is_conversation_view_with_near(): boolean {
const term_type = this.sorted_term_types();
if (
_.isEqual(term_type, ["channel", "topic", "near"]) ||
_.isEqual(term_type, ["dm", "near"])
) {
return true;
}
return false;
}
excludes_muted_topics(): boolean { excludes_muted_topics(): boolean {
return ( return (
// not narrowed to a topic // not narrowed to a topic

View File

@ -10,7 +10,10 @@ import * as util from "./util";
function get_scheduled_messages_matching_narrow(): ScheduledMessage[] { function get_scheduled_messages_matching_narrow(): ScheduledMessage[] {
const scheduled_messages_list = [...scheduled_messages.scheduled_messages_data.values()]; const scheduled_messages_list = [...scheduled_messages.scheduled_messages_data.values()];
const filter = narrow_state.filter(); const filter = narrow_state.filter();
const is_conversation_view = filter === undefined ? false : filter.is_conversation_view(); const is_conversation_view =
filter === undefined
? false
: filter.is_conversation_view() || filter.is_conversation_view_with_near();
const current_view_type = narrow_state.narrowed_to_pms() ? "private" : "stream"; const current_view_type = narrow_state.narrowed_to_pms() ? "private" : "stream";
if (!is_conversation_view) { if (!is_conversation_view) {

View File

@ -181,6 +181,7 @@ test("basics", () => {
assert.ok(filter.can_bucket_by("channel")); assert.ok(filter.can_bucket_by("channel"));
assert.ok(filter.can_bucket_by("channel", "topic")); assert.ok(filter.can_bucket_by("channel", "topic"));
assert.ok(!filter.is_conversation_view()); assert.ok(!filter.is_conversation_view());
assert.ok(filter.is_conversation_view_with_near());
// If our only channel operator is negated, then for all intents and purposes, // 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 // we don't consider ourselves to have a channel operator, because we don't
@ -295,6 +296,22 @@ test("basics", () => {
assert.ok(filter.can_apply_locally()); assert.ok(filter.can_apply_locally());
assert.ok(!filter.is_personal_filter()); 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());
terms = [
{operator: "dm", operand: "joe@example.com"},
{operator: "near", operand: 17},
];
filter = new Filter(terms);
assert.ok(filter.is_non_huddle_pm());
assert.ok(filter.contains_only_private_messages());
assert.ok(!filter.can_mark_messages_read());
assert.ok(filter.supports_collapsing_recipients());
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_with_near());
terms = [{operator: "dm", operand: "joe@example.com,jack@example.com"}]; terms = [{operator: "dm", operand: "joe@example.com,jack@example.com"}];
filter = new Filter(terms); filter = new Filter(terms);
@ -305,6 +322,7 @@ test("basics", () => {
assert.ok(filter.can_apply_locally()); assert.ok(filter.can_apply_locally());
assert.ok(!filter.is_personal_filter()); 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());
// "pm-with" was renamed to "dm" // "pm-with" was renamed to "dm"
terms = [{operator: "pm-with", operand: "joe@example.com"}]; terms = [{operator: "pm-with", operand: "joe@example.com"}];
@ -376,6 +394,7 @@ test("basics", () => {
assert.ok(filter.can_apply_locally()); assert.ok(filter.can_apply_locally());
assert.ok(!filter.is_personal_filter()); 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());
// "stream" was renamed to "channel" // "stream" was renamed to "channel"
terms = [ terms = [
@ -393,6 +412,7 @@ test("basics", () => {
assert.ok(filter.can_apply_locally()); assert.ok(filter.can_apply_locally());
assert.ok(!filter.is_personal_filter()); 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());
}); });
function assert_not_mark_read_with_has_operands(additional_terms_to_test) { function assert_not_mark_read_with_has_operands(additional_terms_to_test) {