Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
compose_fade: Use user_ids directly instead of email round-trip.
Shubham Padiad2162570c9d0
diff --git a/web/src/compose_fade.ts b/web/src/compose_fade.tsindex 842e47ee650..665141b9675 100644--- a/web/src/compose_fade.ts+++ b/web/src/compose_fade.ts@@ -3,13 +3,12 @@ import _ from "lodash";import assert from "minimalistic-assert";import * as compose_fade_helper from "./compose_fade_helper.ts";+import * as compose_pm_pill from "./compose_pm_pill.ts";import * as compose_state from "./compose_state.ts";import type {MessageGroup} from "./message_list_view.ts";import * as message_lists from "./message_lists.ts";import * as message_viewport from "./message_viewport.ts";-import * as people from "./people.ts";import * as rows from "./rows.ts";-import * as util from "./util.ts";let normal_display = false;@@ -32,15 +31,9 @@ export function set_focused_recipient(msg_type?: "private" | "stream"): void {};}} else if (msg_type === "private") {- // Normalize the recipient list so it matches the one used when- // adding the message (see message_helper.process_new_message()).- const reply_to = util.normalize_recipients(- compose_state.private_message_recipient_emails(),- );- const to_user_ids = people.reply_to_to_user_ids_string(reply_to);+ const to_user_ids = compose_pm_pill.get_user_ids_string();focused_recipient = {type: msg_type,- reply_to,to_user_ids,};}@@ -85,7 +78,7 @@ function fade_messages(): void {if (message_lists.current !== expected_msg_list ||!compose_state.composing() ||- compose_state.private_message_recipient_emails() !== expected_recipient+ compose_pm_pill.get_user_ids_string() !== expected_recipient) {return;}@@ -103,7 +96,7 @@ function fade_messages(): void {},0,message_lists.current,- compose_state.private_message_recipient_emails(),+ compose_pm_pill.get_user_ids_string(),);}diff --git a/web/src/compose_fade_helper.ts b/web/src/compose_fade_helper.tsindex 5bea9baa04d..c18e8a5a01b 100644--- a/web/src/compose_fade_helper.ts+++ b/web/src/compose_fade_helper.ts@@ -47,5 +47,5 @@ export function want_normal_display(): boolean {}}- return focused_recipient.type === "private" && focused_recipient.reply_to === "";+ return focused_recipient.type === "private" && !focused_recipient.to_user_ids;}diff --git a/web/src/util.ts b/web/src/util.tsindex 84e56bf2080..74d7d046824 100644--- a/web/src/util.ts+++ b/web/src/util.ts@@ -76,7 +76,7 @@ export function extract_pm_recipients(recipients: string): string[] {// When the type is "private", properties from to_user_ids might be undefined.// See https://github.com/zulip/zulip/pull/23032#discussion_r1038480596.export type Recipient =- | {type: "private"; to_user_ids?: string | undefined; reply_to: string}+ | {type: "private"; to_user_ids?: string | undefined}| ({type: "stream"} & StreamTopic);export const same_recipient = function util_same_recipient(a?: Recipient, b?: Recipient): boolean {diff --git a/web/tests/compose_fade.test.cjs b/web/tests/compose_fade.test.cjsindex 613e49925cd..623149f8285 100644--- a/web/tests/compose_fade.test.cjs+++ b/web/tests/compose_fade.test.cjs@@ -131,14 +131,13 @@ run_test("want_normal_display", ({override, override_rewire}) => {// Private message with no recipient.compose_fade_helper.set_focused_recipient({type: "private",- reply_to: "",});assert.ok(compose_fade_helper.want_normal_display());// Private message with a recipient.compose_fade_helper.set_focused_recipient({type: "private",- reply_to: "[email protected]",+ to_user_ids: "31",});assert.ok(!compose_fade_helper.want_normal_display());});