Skip to content

Commit

Permalink
fix: account id update issue (#277)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rickk137 authored May 22, 2024
1 parent 57ed912 commit 3285fb9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
1 change: 0 additions & 1 deletion liquidity/components/AccountsSelector/AccountsSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ export function AccountsSelectorUi({

return (
<>
{/* // Temporarily disable account selector menu */}
<Menu>
{isLoading ? (
<Skeleton startColor="whiteAlpha.500" endColor="whiteAlpha.200">
Expand Down
17 changes: 16 additions & 1 deletion liquidity/ui/src/layouts/Default/NetworkController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,28 @@ export function NetworkController() {
const [toolTipLabel, setTooltipLabel] = useState('Copy');
const { activeWallet, walletsInfo, connect, disconnect } = useWallet();
const { network: activeNetwork, setNetwork } = useNetwork();
const { data: accounts } = useAccounts();
const {
data: accounts,
isLoading: isAccountsLoading,
isFetching: isAccountsFetching,
} = useAccounts();
const { mutation } = useCreateAccount();
const [showTestnets, setShowTestnets] = useLocalStorage(LOCAL_STORAGE_KEYS.SHOW_TESTNETS, false);
const [queryParams] = useSearchParams();
const navigate = useNavigate();
const { pathname } = useLocation();

useEffect(() => {
if (!isAccountsLoading && !isAccountsFetching && accounts) {
const accountId = queryParams.get('accountId');

if (accountId && !accounts?.includes(accountId)) {
queryParams.set('accountId', accounts[0]);
navigate({ pathname, search: accounts[0] ? queryParams.toString() : '' });
}
}
}, [accounts, isAccountsLoading, isAccountsFetching, queryParams, navigate, pathname]);

useEffect(() => {
// Check if wallet preference is stored in local storage
if (!walletsInfo) {
Expand Down

0 comments on commit 3285fb9

Please sign in to comment.