Browse Source

Do not display AccessTokenSettings while loading currentUser

Shun Miyazawa 11 months ago
parent
commit
68616cfff1
1 changed files with 5 additions and 2 deletions
  1. 5 2
      apps/app/src/client/components/Me/ApiSettings.tsx

+ 5 - 2
apps/app/src/client/components/Me/ApiSettings.tsx

@@ -11,7 +11,9 @@ import { ApiTokenSettings } from './ApiTokenSettings';
 const ApiSettings = React.memo((): JSX.Element => {
 
   const { t } = useTranslation();
-  const { data: currentUser } = useCurrentUser();
+  const { data: currentUser, isLoading: isLoadingCurrentUserData } = useCurrentUser();
+
+  const shouldHideAccessTokenSettings = isLoadingCurrentUserData || !currentUser?.readOnly;
 
   return (
     <>
@@ -19,7 +21,8 @@ const ApiSettings = React.memo((): JSX.Element => {
         <h2 className="border-bottom pb-2 my-4 fs-4">{ t('API Token Settings') }</h2>
         <ApiTokenSettings />
       </div>
-      {!currentUser?.readOnly && (
+
+      {shouldHideAccessTokenSettings && (
         <div className="mt-4">
           <h2 className="border-bottom pb-2 my-4 fs-4">{ t('Access Token Settings') }</h2>
           <AccessTokenSettings />