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.

narrow-state: Move pm_emails_string logic to pm_ids_string.

Lauryn Menardbe4af123666c
diff --git a/web/src/narrow_state.ts b/web/src/narrow_state.ts
index 724e4743e49..a44f9b363f1 100644
--- a/web/src/narrow_state.ts
+++ b/web/src/narrow_state.ts
@@ -9,6 +9,7 @@ import type {NarrowTerm} from "./state_data.ts";
import * as stream_data from "./stream_data.ts";
import type {StreamSubscription} from "./sub_store.ts";
import * as unread from "./unread.ts";
+import * as util from "./util.ts";
export function filter(): Filter | undefined {
// We use Filter objects for message views as well as the list of
@@ -189,18 +190,22 @@ export function topic(current_filter: Filter | undefined = filter()): string | u
return undefined;
}
-export function pm_ids_string(filter?: Filter): string | undefined {
- // If you are narrowed to a group direct message with
- // users 4, 5, and 99, this will return "4,5,99"
- const emails_string = pm_emails_string(filter);
-
- if (!emails_string) {
+export function pm_ids_string(current_filter: Filter | undefined = filter()): string | undefined {
+ if (current_filter === undefined) {
return undefined;
}
- const user_ids_string = people.reply_to_to_user_ids_string(emails_string);
+ const operands = current_filter.operands("dm");
+ if (operands.length !== 1) {
+ return undefined;
+ }
- return user_ids_string;
+ // If you are narrowed to a group direct message with users 4, 5, and 99,
+ // this will return "4,5,99". Will return undefined when the value of the
+ // operand string does not translate to a comma-separated list of valid
+ // user emails.
+ const emails_string = util.the(operands);
+ return people.reply_to_to_user_ids_string(emails_string);
}
export function pm_ids_set(filter?: Filter): Set<number> {
@@ -209,21 +214,6 @@ export function pm_ids_set(filter?: Filter): Set<number> {
return new Set(pm_ids_list);
}
-export function pm_emails_string(
- current_filter: Filter | undefined = filter(),
-): string | undefined {
- if (current_filter === undefined) {
- return undefined;
- }
-
- const operands = current_filter.operands("dm");
- if (operands.length !== 1) {
- return undefined;
- }
-
- return operands[0];
-}
-
// We expect get_first_unread_info and therefore _possible_unread_message_ids
// to always be called with a filter from a message list.
export let get_first_unread_info = (