settings: Refactor check_profile_incomplete.

Split the logic of check_profile_incomplete into two functions
show_profile_incomplete and check_profile_incomplete.

The latter is passed to the former which shows the message if the
profile is incomplete.
This commit is contained in:
Tushar912 2021-03-04 23:58:02 +05:30 committed by Tim Abbott
parent 432751c319
commit cda3da18f4
2 changed files with 11 additions and 6 deletions

View File

@ -50,7 +50,7 @@ function should_show_notifications(ls) {
export function check_profile_incomplete() {
if (!page_params.is_admin) {
return;
return false;
}
// Eventually, we might also check page_params.realm_icon_source,
@ -60,6 +60,13 @@ export function check_profile_incomplete() {
page_params.realm_description === "" ||
/^Organization imported from [A-Za-z]+[!.]$/.test(page_params.realm_description)
) {
return true;
}
return false;
}
export function show_profile_incomplete(is_profile_incomplete) {
if (is_profile_incomplete) {
$("[data-process='profile-incomplete']").show();
} else {
$("[data-process='profile-incomplete']").hide();
@ -78,10 +85,8 @@ export function initialize() {
open($("[data-process='notifications']"));
} else if (unread_ui.should_display_bankruptcy_banner()) {
open($("[data-process='bankruptcy']"));
} else {
// TODO: This should be restructured with separate check and
// show calls.
check_profile_incomplete();
} else if (check_profile_incomplete()) {
open($("[data-process='profile-incomplete']"));
}
// Configure click handlers.

View File

@ -252,7 +252,7 @@ export function dispatch_normal_event(event) {
if (page_params.is_admin) {
// Update the UI notice about the user's profile being
// incomplete, as we might have filled in the missing field(s).
panels.check_profile_incomplete();
panels.show_profile_incomplete(panels.check_profile_incomplete());
}
break;
}