From 6d520b7be5c49c63488cb718843d73d3fd9ca18e Mon Sep 17 00:00:00 2001 From: Marwin Hochfelsner <50826859+hlfan@users.noreply.github.com> Date: Sat, 8 Aug 2026 08:42:35 +0200 Subject: [PATCH] Deduplicate social link row removal logic --- app/assets/javascripts/user.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/user.js b/app/assets/javascripts/user.js index eb87ee91d..f02dc05fa 100644 --- a/app/assets/javascripts/user.js +++ b/app/assets/javascripts/user.js @@ -20,8 +20,7 @@ $(function () { if (destroyCheckbox) { destroyCheckbox.checked = true; - row.addClass("d-none"); - row.find("input[type='text']").removeAttr("required"); + removeSocialLinkRow.bind(this)(); } else { row.remove(); } @@ -29,13 +28,15 @@ $(function () { renumberSocialLinks(); }); - $(".social_link_destroy input[type='checkbox']:checked").each(function () { - $(this).closest(".row").addClass("d-none").find("input[type='text']").removeAttr("required"); - }); + $(".social_link_destroy input[type='checkbox']:checked").each(removeSocialLinkRow); renumberSocialLinks(); } + function removeSocialLinkRow() { + $(this).closest(".row").addClass("d-none").find("input[type='text']").removeAttr("required"); + } + function renumberSocialLinks() { $("#social_links .row:not(.d-none)").each(function (i) { const inputLabel = OSM.i18n.t("javascripts.profile.social_link_n", { n: i + 1 }); -- 2.47.3