diff --git a/src/ui/components/PrivateRoute.tsx b/src/ui/components/PrivateRoute.tsx index 45e93496d..e64b5be3b 100644 --- a/src/ui/components/PrivateRoute.tsx +++ b/src/ui/components/PrivateRoute.tsx @@ -3,6 +3,9 @@ import { Navigate } from 'react-router'; import { useWallet } from '@/ui/hooks/use-wallet'; +import { getUiType } from '../utils'; +import { openInternalPageInTab } from '../utils/webapi'; + const PrivateRoute = ({ children }) => { const wallet = useWallet(); @@ -10,6 +13,7 @@ const PrivateRoute = ({ children }) => { const [unlocked, setUnlocked] = useState(false); const [loading, setLoading] = useState(true); + const uiType = getUiType(); // Everything through the wallet controller is async, so we need to check if the wallet is booted and unlocked in a useEffect useEffect(() => { let mounted = true; @@ -40,11 +44,18 @@ const PrivateRoute = ({ children }) => { }, [wallet]); if (loading) { + // If we haven't loaded, we can't make a decision on whether to render the children + // so we return null return null; } if (!booted) { - return ; + if (uiType.isTab) { + return ; + } else { + openInternalPageInTab('welcome'); + return null; + } } if (!unlocked) { diff --git a/src/ui/views/Dashboard/wallet-tab.tsx b/src/ui/views/Dashboard/wallet-tab.tsx index d106c5316..90ce9560f 100644 --- a/src/ui/views/Dashboard/wallet-tab.tsx +++ b/src/ui/views/Dashboard/wallet-tab.tsx @@ -63,7 +63,7 @@ const WalletTab = ({ network }) => { flexDirection: 'column', backgroundColor: 'black', width: '100%', - height: '100%', + minHeight: '100%', }} > { approval = undefined; } - if (!(await wallet.isBooted()) && !isInTab) { - openInternalPageInTab('welcome'); + // For fresh installation, go to welcome page regardless of popup/tab mode + if (!(await wallet.isBooted())) { + if (isInTab) { + setTo('/welcome'); + } else { + openInternalPageInTab('welcome'); + } return; }