From c2c9d11c668112c3cf315ceb645fb5fe5f7d6d07 Mon Sep 17 00:00:00 2001
From: AAGaming <aa@mail.catvibers.me>
Date: Wed, 28 Dec 2022 12:23:42 -0500
Subject: fix broken valveInternal when on a multi-user deck

---
 frontend/src/developer.tsx | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

(limited to 'frontend/src/developer.tsx')

diff --git a/frontend/src/developer.tsx b/frontend/src/developer.tsx
index e4e4b335..1d6b3fb2 100644
--- a/frontend/src/developer.tsx
+++ b/frontend/src/developer.tsx
@@ -27,13 +27,20 @@ const logger = new Logger('DeveloperMode');
 
 let removeSettingsObserver: () => void = () => {};
 
-export function setShowValveInternal(show: boolean) {
-  const settingsMod = findModuleChild((m) => {
-    if (typeof m !== 'object') return undefined;
-    for (let prop in m) {
-      if (typeof m[prop]?.settings?.bIsValveEmail !== 'undefined') return m[prop];
+export async function setShowValveInternal(show: boolean) {
+  let settingsMod: any;
+  while (!settingsMod) {
+    settingsMod = findModuleChild((m) => {
+      if (typeof m !== 'object') return undefined;
+      for (let prop in m) {
+        if (typeof m[prop]?.settings?.bIsValveEmail !== 'undefined') return m[prop];
+      }
+    });
+    if (!settingsMod) {
+      logger.debug('[ValveInternal] waiting for settingsMod');
+      await sleep(1000);
     }
-  });
+  }
 
   if (show) {
     removeSettingsObserver = settingsMod[
-- 
cgit v1.2.3

