From 4815c3cc33384e20a0d4404439e86724ca6785ae Mon Sep 17 00:00:00 2001
From: Greg Fodor <gfodor@gmail.com>
Date: Fri, 13 Jul 2018 18:15:45 +0000
Subject: [PATCH] Add polling loop for build version

---
 src/assets/translations.data.json | 1 +
 src/hub.js                        | 7 +++++++
 webpack.config.js                 | 3 ++-
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/assets/translations.data.json b/src/assets/translations.data.json
index 79d115995..1f8ae6a1b 100644
--- a/src/assets/translations.data.json
+++ b/src/assets/translations.data.json
@@ -40,6 +40,7 @@
     "exit.subtitle.closed": "This room is no longer available.",
     "exit.subtitle.full": "This room is full, please try again later.",
     "exit.subtitle.connect_error": "Unable to connect to this room, please try again later.",
+    "exit.subtitle.version_mismatch": "The version you deployed is not available yet. Your browser will refresh in 5 seconds.",
     "autoexit.title": "Auto-ending session in ",
     "autoexit.title_units": " seconds",
     "autoexit.subtitle": "You have started another session.",
diff --git a/src/hub.js b/src/hub.js
index fa2114911..d66de1f4f 100644
--- a/src/hub.js
+++ b/src/hub.js
@@ -432,6 +432,13 @@ const onReady = async () => {
     return;
   }
 
+  if (qs.required_version && qs.required_version !== process.env.BUILD_VERSION) {
+    remountUI({ roomUnavailableReason: "version_mismatch" });
+    setTimeout(() => document.location.reload(), 5000);
+    exitScene();
+    return;
+  }
+
   getAvailableVREntryTypes().then(availableVREntryTypes => {
     if (availableVREntryTypes.gearvr === VR_DEVICE_AVAILABILITY.yes) {
       remountUI({ availableVREntryTypes, forcedVREntryType: "gearvr" });
diff --git a/webpack.config.js b/webpack.config.js
index 3c92d1b38..163ddf37f 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -266,7 +266,8 @@ const config = {
         NODE_ENV: process.env.NODE_ENV,
         JANUS_SERVER: process.env.JANUS_SERVER,
         DEV_RETICULUM_SERVER: process.env.DEV_RETICULUM_SERVER,
-        ASSET_BUNDLE_SERVER: process.env.ASSET_BUNDLE_SERVER
+        ASSET_BUNDLE_SERVER: process.env.ASSET_BUNDLE_SERVER,
+        BUILD_VERSION: process.env.BUILD_VERSION
       })
     })
   ]
-- 
GitLab