mirror of
https://github.com/zulip/zulip.git
synced 2026-06-27 21:01:32 +08:00
subscriber_api: Don't return unused channel request objects.
This commit is contained in:
parent
5230aada2b
commit
5891a9ef24
@ -14,20 +14,21 @@ export function add_user_ids_to_stream(
|
||||
sub: StreamSubscription,
|
||||
success: () => void,
|
||||
failure: (xhr: JQuery.jqXHR<unknown>) => void,
|
||||
): JQuery.jqXHR<unknown> | undefined {
|
||||
): void {
|
||||
// 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]))) {
|
||||
// Self subscribe
|
||||
const color = sub.color;
|
||||
return channel.post({
|
||||
void channel.post({
|
||||
url: "/json/users/me/subscriptions",
|
||||
data: {subscriptions: JSON.stringify([{name: stream_name, color}])},
|
||||
success,
|
||||
error: failure,
|
||||
});
|
||||
return;
|
||||
}
|
||||
return channel.post({
|
||||
void channel.post({
|
||||
url: "/json/users/me/subscriptions",
|
||||
data: {
|
||||
subscriptions: JSON.stringify([{name: stream_name}]),
|
||||
@ -43,10 +44,10 @@ export function remove_user_id_from_stream(
|
||||
sub: StreamSubscription,
|
||||
success: () => void,
|
||||
failure: (xhr: JQuery.jqXHR<unknown>) => void,
|
||||
): JQuery.jqXHR<unknown> | undefined {
|
||||
): void {
|
||||
// TODO: use stream_id when backend supports it
|
||||
const stream_name = sub.name;
|
||||
return channel.del({
|
||||
void channel.del({
|
||||
url: "/json/users/me/subscriptions",
|
||||
data: {subscriptions: JSON.stringify([stream_name]), principals: JSON.stringify([user_id])},
|
||||
success,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user