diff --git a/web/src/compose_setup.js b/web/src/compose_setup.js index 4b0e1cbf2d..2025734d4e 100644 --- a/web/src/compose_setup.js +++ b/web/src/compose_setup.js @@ -252,7 +252,7 @@ export function initialize() { const {$banner_container} = get_input_info(event); const $invite_row = $(event.target).parents(".main-view-banner"); - const user_id = Number.parseInt($invite_row.data("user-id"), 10); + const user_id = Number($invite_row.attr("data-user-id")); const stream_id = Number($invite_row.attr("data-stream-id")); function success() { diff --git a/web/src/compose_validate.ts b/web/src/compose_validate.ts index cbbba3bd90..cb11bedc02 100644 --- a/web/src/compose_validate.ts +++ b/web/src/compose_validate.ts @@ -223,7 +223,7 @@ export function warn_if_mentioning_unsubscribed_user( ); const existing_invites = [...$existing_invites_area].map((user_row) => - Number.parseInt($(user_row).data("user-id"), 10), + Number($(user_row).attr("data-user-id")), ); const can_subscribe_other_users = settings_data.user_can_subscribe_other_users(); diff --git a/web/src/settings_users.js b/web/src/settings_users.js index 534a925cdc..d7741c2789 100644 --- a/web/src/settings_users.js +++ b/web/src/settings_users.js @@ -441,7 +441,7 @@ function handle_deactivation($tbody) { e.stopPropagation(); const $row = $(e.target).closest(".user_row"); - const user_id = $row.data("user-id"); + const user_id = Number($row.attr("data-user-id")); function handle_confirm() { const url = "/json/users/" + encodeURIComponent(user_id); diff --git a/web/src/user_profile.js b/web/src/user_profile.js index 921c917a97..2e52a861bd 100644 --- a/web/src/user_profile.js +++ b/web/src/user_profile.js @@ -79,7 +79,7 @@ function compare_by_name(a, b) { export function get_user_id_if_user_profile_modal_open() { if (modals.any_active() && modals.active_modal() === "#user-profile-modal") { - const user_id = $("#user-profile-modal").data("user-id"); + const user_id = Number($("#user-profile-modal").attr("data-user-id")); return user_id; } return undefined; @@ -675,7 +675,7 @@ export function show_edit_bot_info_modal(user_id, $container) { $("#bot-edit-form").on("click", ".deactivate_bot_button", (e) => { e.preventDefault(); e.stopPropagation(); - const bot_id = $("#bot-edit-form").data("user-id"); + const bot_id = Number($("#bot-edit-form").attr("data-user-id")); function handle_confirm() { const url = "/json/bots/" + encodeURIComponent(bot_id); dialog_widget.submit_api_request(channel.del, url, {}); @@ -687,7 +687,7 @@ export function show_edit_bot_info_modal(user_id, $container) { $("#bot-edit-form").on("click", ".reactivate_user_button", (e) => { e.preventDefault(); e.stopPropagation(); - const user_id = $("#bot-edit-form").data("user-id"); + const user_id = Number($("#bot-edit-form").attr("data-user-id")); function handle_confirm() { const url = "/json/users/" + encodeURIComponent(user_id) + "/reactivate"; dialog_widget.submit_api_request(channel.post, url, {}); @@ -787,7 +787,7 @@ export function show_edit_user_info_modal(user_id, $container) { $("#edit-user-form").on("click", ".deactivate_user_button", (e) => { e.preventDefault(); e.stopPropagation(); - const user_id = $("#edit-user-form").data("user-id"); + const user_id = Number($("#edit-user-form").attr("data-user-id")); function handle_confirm() { const url = "/json/users/" + encodeURIComponent(user_id); dialog_widget.submit_api_request(channel.del, url, {}); @@ -799,7 +799,7 @@ export function show_edit_user_info_modal(user_id, $container) { $("#edit-user-form").on("click", ".reactivate_user_button", (e) => { e.preventDefault(); e.stopPropagation(); - const user_id = $("#edit-user-form").data("user-id"); + const user_id = Number($("#edit-user-form").attr("data-user-id")); function handle_confirm() { const url = "/json/users/" + encodeURIComponent(user_id) + "/reactivate"; dialog_widget.submit_api_request(channel.post, url, {}); diff --git a/web/tests/compose_validate.test.js b/web/tests/compose_validate.test.js index 57a783225d..f821644cc8 100644 --- a/web/tests/compose_validate.test.js +++ b/web/tests/compose_validate.test.js @@ -732,10 +732,7 @@ test_ui("warn_if_mentioning_unsubscribed_user", ({override, mock_template}) => { // Simulate that the row was added to the DOM. const $warning_row = $("#compose_banners .recipient_not_subscribed"); - $warning_row.data = (key) => - ({ - "user-id": "34", - })[key]; + $warning_row.attr("data-user-id", "34"); $warning_row.attr("data-stream-id", "111"); $("#compose_banners .recipient_not_subscribed").length = 1; $("#compose_banners .recipient_not_subscribed")[0] = $warning_row;