compose: Extract a compose_recipient module.

This helps reduce the amount of import cycles we have in the compose
code path following the migration to a fancier stream input.

`compose_closed_ui.initialize()` was moved further down in the
initialization order because it relies on the dropdown widget
to be defined.
This commit is contained in:
evykassirer
2023-03-30 21:27:36 -07:00
committed by Tim Abbott
parent 5948671f92
commit 0c706aeafc
23 changed files with 268 additions and 245 deletions

View File

@@ -41,7 +41,7 @@ const peer_data = zrequire("peer_data");
const people = zrequire("people");
const stream_data = zrequire("stream_data");
const stream_events = zrequire("stream_events");
const compose_ui = zrequire("compose_ui");
const compose_recipient = zrequire("compose_recipient");
const george = {
email: "george@zulip.com",
@@ -88,8 +88,8 @@ function test(label, f) {
}
test("update_property", ({override, override_rewire}) => {
override_rewire(compose_ui, "update_stream_dropdown_options", noop);
override_rewire(compose_ui, "possibly_update_dropdown_selection", noop);
override_rewire(compose_recipient, "update_stream_dropdown_options", noop);
override_rewire(compose_recipient, "possibly_update_dropdown_selection", noop);
const sub = {...frontend};
stream_data.add_sub(sub);
@@ -284,7 +284,7 @@ test("marked_subscribed (normal)", ({override, override_rewire}) => {
const sub = {...frontend};
stream_data.add_sub(sub);
override(stream_color, "update_stream_color", noop);
override_rewire(compose_ui, "update_stream_dropdown_options", noop);
override_rewire(compose_recipient, "update_stream_dropdown_options", noop);
narrow_to_frontend();
@@ -323,7 +323,7 @@ test("marked_subscribed (color)", ({override, override_rewire}) => {
override(stream_list, "add_sidebar_row", noop);
override(stream_list, "update_subscribe_to_more_streams_link", noop);
override(unread_ui, "update_unread_counts", noop);
override_rewire(compose_ui, "update_stream_dropdown_options", noop);
override_rewire(compose_recipient, "update_stream_dropdown_options", noop);
const sub = {
subscribed: false,
@@ -356,7 +356,7 @@ test("marked_subscribed (emails)", ({override, override_rewire}) => {
const sub = {...frontend};
stream_data.add_sub(sub);
override(stream_color, "update_stream_color", noop);
override_rewire(compose_ui, "update_stream_dropdown_options", noop);
override_rewire(compose_recipient, "update_stream_dropdown_options", noop);
// Test assigning subscriber emails
// narrow state is undefined
@@ -395,7 +395,7 @@ test("mark_unsubscribed (update_settings_for_unsubscribed)", ({override, overrid
$("#streams_overlay_container .stream-row:not(.notdisplayed)").length = 0;
override_rewire(compose_ui, "update_stream_dropdown_options", noop);
override_rewire(compose_recipient, "update_stream_dropdown_options", noop);
stream_events.mark_unsubscribed(sub);
const args = stub.get_args("sub");
assert.deepEqual(args.sub, sub);
@@ -422,7 +422,7 @@ test("mark_unsubscribed (render_title_area)", ({override, override_rewire}) => {
$("#streams_overlay_container .stream-row:not(.notdisplayed)").length = 0;
override_rewire(compose_ui, "update_stream_dropdown_options", noop);
override_rewire(compose_recipient, "update_stream_dropdown_options", noop);
stream_events.mark_unsubscribed(sub);
assert.equal(message_view_header_stub.num_calls, 1);