subscribers: Extract subscriber_api.

This simplifies some of our dependencies.

As an example, we really don't want compose.js
to depend on stream_subscribers_ui.js, since
the former doesn't use any actual UI code from
the latter.

We also rename the two functions here:

    invite_user_to_stream -> add_user_ids_to_stream
    remove_user_from_stream -> remove_user_id_from_stream

(The notion of "inviting" somebody to a stream is
somewhat misleading, since there is really no invitation
mechanism; you just add them.)

Apart from naming changes this is a verbatim code move.

Finally, we eliminate a little bit of test cruft--the
`override` helper already ensures that a function gets
called at least once during a test.
This commit is contained in:
Steve Howell
2022-02-21 14:28:56 +00:00
committed by Tim Abbott
parent 57398c9933
commit 65b51ae3bd
6 changed files with 54 additions and 38 deletions

View File

@@ -27,8 +27,8 @@ import * as sent_messages from "./sent_messages";
import * as server_events from "./server_events";
import * as stream_data from "./stream_data";
import * as stream_settings_ui from "./stream_settings_ui";
import * as stream_subscribers_ui from "./stream_subscribers_ui";
import * as sub_store from "./sub_store";
import * as subscriber_api from "./subscriber_api";
import * as transmit from "./transmit";
import * as ui_report from "./ui_report";
import * as upload from "./upload";
@@ -507,7 +507,7 @@ export function initialize() {
const sub = sub_store.get(stream_id);
stream_subscribers_ui.invite_user_to_stream([user_id], sub, success, xhr_failure);
subscriber_api.add_user_ids_to_stream([user_id], sub, success, xhr_failure);
});
$("#compose_invite_users").on("click", ".compose_invite_close", (event) => {