Skip to content
This repository was archived by the owner on Mar 2, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/ui/components/PrivateRoute.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@ 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();

const [booted, setBooted] = useState(false);
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;
Expand Down Expand Up @@ -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 <Navigate to="/welcome" replace />;
if (uiType.isTab) {
return <Navigate to="/welcome" replace />;
} else {
openInternalPageInTab('welcome');
return null;
}
Comment on lines +53 to +58

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The openInternalPageInTab call could potentially fail, but there's no error handling. Consider wrapping this in a try-catch block to handle potential failures gracefully and provide feedback to the user if the tab fails to open.

}

if (!unlocked) {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/views/Dashboard/wallet-tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const WalletTab = ({ network }) => {
flexDirection: 'column',
backgroundColor: 'black',
width: '100%',
height: '100%',
minHeight: '100%',
}}
>
<Tabs
Expand Down
9 changes: 7 additions & 2 deletions src/ui/views/SortHat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,13 @@ const SortHat = () => {
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;
}

Expand Down
Loading