Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
compose_call: Use a workaround for JQuery.jqXHR.abort.
apoorvapendsef31c56868927
diff --git a/web/src/compose_call.ts b/web/src/compose_call.tsindex c96d233bb07..065f4740ad3 100644--- a/web/src/compose_call.ts+++ b/web/src/compose_call.ts@@ -2,6 +2,7 @@ import {realm} from "./state_data.ts";export const zoom_token_callbacks = new Map();export const video_call_xhrs = new Map<string, JQuery.jqXHR<unknown>>();+export const ignored_call_xhrs = new Set<JQuery.jqXHR>();export function get_jitsi_server_url(video_call_id?: string): URL | null {const base_url = realm.realm_jitsi_server_url ?? realm.server_jitsi_server_url;@@ -19,7 +20,10 @@ export function abort_video_callbacks(edit_message_id = ""): void {zoom_token_callbacks.delete(edit_message_id);const xhr = video_call_xhrs.get(edit_message_id);if (xhr !== undefined) {- xhr.abort();+ // TODO: Use xhr.abort(), if XHR methods are available+ // after https://github.com/getsentry/sentry-javascript/issues/19242+ // gets resolved.+ ignored_call_xhrs.add(xhr);video_call_xhrs.delete(edit_message_id);}}diff --git a/web/src/compose_call_ui.ts b/web/src/compose_call_ui.tsindex a68719adbe5..35a5d2c992e 100644--- a/web/src/compose_call_ui.ts+++ b/web/src/compose_call_ui.ts@@ -58,6 +58,7 @@ export function generate_and_insert_audio_or_video_call_link($target_textarea = $<HTMLTextAreaElement>("textarea#compose-textarea");}+ let xhr: JQuery.jqXHR<unknown> | undefined;const available_providers = realm.realm_available_video_chat_providers;const provider_is_zoom = realm.realm_video_chat_provider === available_providers.zoom?.id;const provider_is_zoom_server_to_server =@@ -72,10 +73,13 @@ export function generate_and_insert_audio_or_video_call_link(};const make_zoom_call = (): void => {- const xhr = channel.post({+ xhr = channel.post({url: "/json/calls/zoom/create",data: request,success(res) {+ if (xhr && compose_call.ignored_call_xhrs.has(xhr)) {+ return;+ }const data = call_response_schema.parse(res);compose_call.video_call_xhrs.delete(key);if (is_audio_call) {@@ -84,9 +88,12 @@ export function generate_and_insert_audio_or_video_call_link(insert_video_call_url(data.url, $target_textarea);}},- error(xhr, status) {+ error(_xhr, status) {+ if (xhr && compose_call.ignored_call_xhrs.has(xhr)) {+ return;+ }compose_call.video_call_xhrs.delete(key);- const parsed = z.object({code: z.string()}).safeParse(xhr.responseJSON);+ const parsed = z.object({code: z.string()}).safeParse(_xhr.responseJSON);if (status === "error" &&parsed.success &&@@ -149,15 +156,21 @@ export function generate_and_insert_audio_or_video_call_link(compose_call.abort_video_callbacks(edit_message_id);const key = edit_message_id ?? "";- const xhr = channel.post({+ xhr = channel.post({url: "/json/calls/constructorgroups/create",data: {},success(response) {+ if (xhr && compose_call.ignored_call_xhrs.has(xhr)) {+ return;+ }const data = call_response_schema.parse(response);compose_call.video_call_xhrs.delete(key);insert_video_call_url(data.url, $target_textarea);},error(_xhr, status) {+ if (xhr && compose_call.ignored_call_xhrs.has(xhr)) {+ return;+ }compose_call.video_call_xhrs.delete(key);if (status !== "abort") {ui_report.generic_embed_error(