From 483954dd2c7ae5819278baf5cce2584a5c32012b Mon Sep 17 00:00:00 2001
From: Brian Peiris <brianpeiris@gmail.com>
Date: Tue, 10 Apr 2018 13:02:48 -0700
Subject: [PATCH] show profile entry panel if profile has not been saved

---
 src/hub.js                                  | 4 +++-
 src/react-components/profile-entry-panel.js | 1 +
 src/react-components/ui-root.js             | 8 +++++++-
 src/storage/store.js                        | 1 +
 src/utils/identity.js                       | 1 +
 5 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/hub.js b/src/hub.js
index fc8436499..6d9223d33 100644
--- a/src/hub.js
+++ b/src/hub.js
@@ -210,6 +210,7 @@ function mountUI(scene) {
   const forcedVREntryType = qs.vr_entry_type || null;
   const enableScreenSharing = qsTruthy("enable_screen_sharing");
   const htmlPrefix = document.body.dataset.htmlPrefix || "";
+  const showProfileEntry = !store.state.profile.has_saved_profile;
 
   // TODO: Refactor to avoid using return value
   /* eslint-disable react/no-render-return-value */
@@ -224,7 +225,8 @@ function mountUI(scene) {
         forcedVREntryType,
         enableScreenSharing,
         store,
-        htmlPrefix
+        htmlPrefix,
+        showProfileEntry
       }}
     />,
     document.getElementById("ui-root")
diff --git a/src/react-components/profile-entry-panel.js b/src/react-components/profile-entry-panel.js
index 523016e25..af1c7382f 100644
--- a/src/react-components/profile-entry-panel.js
+++ b/src/react-components/profile-entry-panel.js
@@ -30,6 +30,7 @@ class ProfileEntryPanel extends Component {
     e.preventDefault();
     this.props.store.update({
       profile: {
+        has_saved_profile: true,
         display_name: this.state.display_name,
         avatar_id: this.state.avatar_id
       }
diff --git a/src/react-components/ui-root.js b/src/react-components/ui-root.js
index 3970a2305..e4c844bbd 100644
--- a/src/react-components/ui-root.js
+++ b/src/react-components/ui-root.js
@@ -60,7 +60,8 @@ class UIRoot extends Component {
     enableScreenSharing: PropTypes.bool,
     store: PropTypes.object,
     scene: PropTypes.object,
-    htmlPrefix: PropTypes.string
+    htmlPrefix: PropTypes.string,
+    showProfileEntry: PropTypes.bool
   };
 
   state = {
@@ -95,6 +96,11 @@ class UIRoot extends Component {
     janusRoomId: null
   };
 
+  constructor(props) {
+    super(props);
+    this.state.showProfileEntry = this.props.showProfileEntry;
+  }
+
   componentDidMount() {
     this.setupTestTone();
     this.props.concurrentLoadDetector.addEventListener("concurrentload", this.onConcurrentLoad);
diff --git a/src/storage/store.js b/src/storage/store.js
index 6f480aa76..b9f7366ab 100644
--- a/src/storage/store.js
+++ b/src/storage/store.js
@@ -16,6 +16,7 @@ export const SCHEMA = {
       type: "object",
       additionalProperties: false,
       properties: {
+        has_saved_profile: { type: "boolean" },
         display_name: { type: "string", pattern: "^[A-Za-z0-9-]{3,32}$" },
         avatar_id: { type: "string" }
       }
diff --git a/src/utils/identity.js b/src/utils/identity.js
index def830cbc..e4d79896c 100644
--- a/src/utils/identity.js
+++ b/src/utils/identity.js
@@ -172,6 +172,7 @@ export const avatarIds = avatars.map(av => av.id);
 export function generateDefaultProfile() {
   const name = selectRandom(names);
   return {
+    has_saved_profile: false,
     display_name: name.replace(/^./, name[0].toUpperCase()),
     avatar_id: selectRandom(avatarIds)
   };
-- 
GitLab