From ed9874f4d0b327a09aaed28717d98be787f0ebf6 Mon Sep 17 00:00:00 2001
From: MohamedBassem <me@mbassem.com>
Date: Tue, 5 Mar 2024 19:10:31 +0000
Subject: extension: Fix the infinite loading of the options page

---
 packages/browser-extension/src/OptionsPage.tsx | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

(limited to 'packages/browser-extension/src/OptionsPage.tsx')

diff --git a/packages/browser-extension/src/OptionsPage.tsx b/packages/browser-extension/src/OptionsPage.tsx
index 74b2067e..913b69ab 100644
--- a/packages/browser-extension/src/OptionsPage.tsx
+++ b/packages/browser-extension/src/OptionsPage.tsx
@@ -9,11 +9,12 @@ export default function OptionsPage() {
   const navigate = useNavigate();
   const { settings, setSettings } = usePluginSettings();
 
-  const {
-    data: whoami,
-    isPending: isWhoAmiPending,
-    error: whoAmIError,
-  } = api.users.whoami.useQuery();
+  const { data: whoami, error: whoAmIError } = api.users.whoami.useQuery(
+    undefined,
+    {
+      enabled: settings.address != "",
+    },
+  );
 
   const invalidateWhoami = api.useUtils().users.whoami.refetch;
 
@@ -30,12 +31,10 @@ export default function OptionsPage() {
         <span>Something went wrong: {whoAmIError.message}</span>
       );
     }
-  }
-  if (isWhoAmiPending) {
-    loggedInMessage = <Spinner />;
-  }
-  if (whoami) {
+  } else if (whoami) {
     loggedInMessage = <span>{whoami.name}</span>;
+  } else {
+    loggedInMessage = <Spinner />;
   }
 
   const onLogout = () => {
-- 
cgit v1.2.3-70-g09d2

