compose: Move update_email to compose_state.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2023-10-06 00:37:10 -07:00 committed by Tim Abbott
parent 833a15e121
commit c56f784489
4 changed files with 16 additions and 15 deletions

View File

@ -268,18 +268,6 @@ export function do_post_send_tasks() {
$(document).trigger("compose_finished.zulip");
}
export function update_email(user_id, new_email) {
let reply_to = compose_state.private_message_recipient();
if (!reply_to) {
return;
}
reply_to = people.update_email_in_reply_to(reply_to, user_id, new_email);
compose_state.private_message_recipient(reply_to);
}
export function render_and_show_preview($preview_spinner, $preview_content_box, content) {
function show_preview(rendered_content, raw_content) {
// content is passed to check for status messages ("/me ...")

View File

@ -2,6 +2,7 @@ import $ from "jquery";
import * as compose_pm_pill from "./compose_pm_pill";
import {$t} from "./i18n";
import * as people from "./people";
import * as sub_store from "./sub_store";
let message_type = false; // 'stream', 'private', or false-y
@ -185,3 +186,15 @@ export function has_full_recipient() {
}
return private_message_recipient() !== "";
}
export function update_email(user_id, new_email) {
let reply_to = private_message_recipient();
if (!reply_to) {
return;
}
reply_to = people.update_email_in_reply_to(reply_to, user_id, new_email);
private_message_recipient(reply_to);
}

View File

@ -6,7 +6,7 @@ import $ from "jquery";
import * as activity_ui from "./activity_ui";
import * as blueslip from "./blueslip";
import * as compose from "./compose";
import * as compose_state from "./compose_state";
import * as message_live_update from "./message_live_update";
import * as narrow_state from "./narrow_state";
import {page_params} from "./page_params";
@ -34,7 +34,7 @@ export const update_person = function update(person) {
const new_email = person.new_email;
narrow_state.update_email(user_id, new_email);
compose.update_email(user_id, new_email);
compose_state.update_email(user_id, new_email);
if (people.is_my_user_id(person.user_id)) {
page_params.email = new_email;

View File

@ -17,7 +17,7 @@ const settings_account = mock_esm("../src/settings_account", {
mock_esm("../src/activity_ui", {
redraw() {},
});
mock_esm("../src/compose", {
mock_esm("../src/compose_state", {
update_email() {},
});
mock_esm("../src/narrow_state", {