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.

user-profile: Fix duplicate API calls to update user and bots.

Sahil Batra266f76615cff
diff --git a/web/src/user_profile.ts b/web/src/user_profile.ts
index 2f6f9083741..873733e99d2 100644
--- a/web/src/user_profile.ts
+++ b/web/src/user_profile.ts
@@ -908,6 +908,9 @@ export function show_edit_bot_info_modal(user_id: number, $container: JQuery): v
}
toggle_submit_button($("#bot-edit-form"));
});
+ // Remove any previously registered handler to avoid duplicate API
+ // calls when the "Manage bot" tab is opened multiple times.
+ $("#user-profile-modal").off("click", ".dialog_submit_button");
$("#user-profile-modal").on("click", ".dialog_submit_button", () => {
const role = Number.parseInt(
$<HTMLSelectOneElement>("select:not([multiple])#bot-role-select").val()!.trim(),
@@ -1359,6 +1362,9 @@ export function show_edit_user_info_modal(user_id: number, $container: JQuery):
toggle_submit_button($("#edit-user-form"));
});
+ // Remove any previously registered handler to avoid duplicate API
+ // calls when the "Manage user" tab is opened multiple times.
+ $("#user-profile-modal").off("click", ".dialog_submit_button");
$("#user-profile-modal").on("click", ".dialog_submit_button", () => {
const role = Number.parseInt(
$<HTMLSelectOneElement>("select:not([multiple])#user-role-select").val()!.trim(),