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.

subscriber_api: Convert module to TypeScript.

Varun Singh62a636068e2d
diff --git a/tools/test-js-with-node b/tools/test-js-with-node
index e427ba2907f..e2608e289ab 100755
--- a/tools/test-js-with-node
+++ b/tools/test-js-with-node
@@ -240,7 +240,7 @@ EXEMPT_FILES = make_set(
"web/src/stream_settings_ui.js",
"web/src/stream_ui_updates.js",
"web/src/submessage.js",
- "web/src/subscriber_api.js",
+ "web/src/subscriber_api.ts",
"web/src/timerender.ts",
"web/src/tippyjs.ts",
"web/src/todo_widget.js",
diff --git a/web/src/subscriber_api.js b/web/src/subscriber_api.ts
similarity index 74%
rename from web/src/subscriber_api.js
rename to web/src/subscriber_api.ts
index d20793217d1..eb7ebce354f 100644
--- a/web/src/subscriber_api.js
+++ b/web/src/subscriber_api.ts
@@ -1,5 +1,6 @@
import * as channel from "./channel";
import * as people from "./people";
+import type {StreamSubscription} from "./sub_store";
/*
This module simply encapsulates our legacy API for subscribing
@@ -8,7 +9,12 @@ import * as people from "./people";
nor how to JSON.stringify things, nor the URL scheme.
*/
-export function add_user_ids_to_stream(user_ids, sub, success, failure) {
+export function add_user_ids_to_stream(
+ user_ids: number[],
+ sub: StreamSubscription,
+ success: () => void,
+ failure: (xhr: JQuery.jqXHR<unknown>) => void,
+): JQuery.jqXHR<unknown> | undefined {
// TODO: use stream_id when backend supports it
const stream_name = sub.name;
if (user_ids.length === 1 && people.is_my_user_id(Number(user_ids[0]))) {
@@ -32,7 +38,12 @@ export function add_user_ids_to_stream(user_ids, sub, success, failure) {
});
}
-export function remove_user_id_from_stream(user_id, sub, success, failure) {
+export function remove_user_id_from_stream(
+ user_id: number[],
+ sub: StreamSubscription,
+ success: () => void,
+ failure: (xhr: JQuery.jqXHR<unknown>) => void,
+): JQuery.jqXHR<unknown> | undefined {
// TODO: use stream_id when backend supports it
const stream_name = sub.name;
return channel.del({