mirror of
https://github.com/zulip/zulip.git
synced 2026-07-03 21:10:12 +08:00
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:
parent
432751c319
commit
cda3da18f4
@ -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.
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user