Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

settings: Refactor check_profile_incomplete.

Tushar912cda3da18f4f5
diff --git a/static/js/panels.js b/static/js/panels.js
index 9dabfa48820..cd04113044e 100644
--- a/static/js/panels.js
+++ b/static/js/panels.js
@@ -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.
diff --git a/static/js/server_events_dispatch.js b/static/js/server_events_dispatch.js
index c6441ac2300..09dfe533602 100644
--- a/static/js/server_events_dispatch.js
+++ b/static/js/server_events_dispatch.js
@@ -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;
}