navbar_alert: Fix wierd closing of profile-missing-required alert.

This is a follow-up for #28924 to fix weird closing behavior of navbar alert which
is used to show the presence of empty required profile fields.
This commit is contained in:
Vector73 2024-03-26 15:51:53 +05:30 committed by Tim Abbott
parent 38b2988e0f
commit ea5b6be433
1 changed files with 8 additions and 7 deletions

View File

@ -73,6 +73,7 @@ export function should_show_server_upgrade_notification(ls) {
}
export function maybe_show_empty_required_profile_fields_alert() {
const $navbar_alert = $("#navbar_alerts_wrapper").children(".alert").first();
const empty_required_profile_fields_exist = realm.custom_profile_fields
.map((f) => ({
...f,
@ -80,15 +81,13 @@ export function maybe_show_empty_required_profile_fields_alert() {
}))
.find((f) => f.required && !f.value);
if (!empty_required_profile_fields_exist) {
if ($navbar_alert.data("process") === "profile-missing-required") {
$navbar_alert.hide();
}
return;
}
const $navbar_alert = $("#navbar_alerts_wrapper").children(".alert").first();
if (
!$navbar_alert?.length ||
$navbar_alert.is("#empty-required-profile-fields-warning") ||
$navbar_alert.is(":hidden")
) {
if (!$navbar_alert?.length || $navbar_alert.is(":hidden")) {
open({
data_process: "profile-missing-required",
rendered_alert_content_html: render_empty_required_profile_fields(),
@ -236,7 +235,9 @@ export function initialize() {
show_step($process, 2);
} else {
$(this).closest(".alert").hide();
maybe_show_empty_required_profile_fields_alert();
if ($process.data("process") !== "profile-missing-required") {
maybe_show_empty_required_profile_fields_alert();
}
}
$(window).trigger("resize");
});