Skip to content

Commit

Permalink
fix: prev conflict messup when merging pr's
Browse files Browse the repository at this point in the history
  • Loading branch information
kushagrasarathe committed Jan 21, 2025
1 parent 2e545a0 commit 3389e6d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
6 changes: 4 additions & 2 deletions src/app/(mobile-ui)/home/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,15 @@ export default function Home() {
const selectedWalletIndex = rawIndex === -1 ? 0 : rawIndex
const [focusedIndex, setFocusedIndex] = useState(selectedWalletIndex)

// update focusedIndex when selectedWallet changes
// update focusedIndex and focused wallet when selectedWallet changes
useEffect(() => {
const index = wallets.findIndex((wallet) => wallet.address === selectedWallet?.address)
if (index !== -1) {
setFocusedIndex(index)
// also update the focused wallet when selected wallet changes
dispatch(walletActions.setFocusedWallet(wallets[index]))
}
}, [selectedWallet, wallets])
}, [selectedWallet, wallets, dispatch])

const hasWallets = wallets.length > 0
const { handleLogin, isLoggingIn } = useZeroDev()
Expand Down
25 changes: 12 additions & 13 deletions src/app/(mobile-ui)/wallet/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,25 @@ import NavHeader from '@/components/Global/NavHeader'
import { WalletCard } from '@/components/Home/WalletCard'
import { useAuth } from '@/context/authContext'
import { useWallet } from '@/hooks/wallet/useWallet'
import { IUserBalance, WalletProviderType } from '@/interfaces'
import { IUserBalance } from '@/interfaces'
import { useWalletStore } from '@/redux/hooks'
import { formatAmount, getChainName, getUserPreferences, updateUserPreferences } from '@/utils'
import { useAppKit, useDisconnect } from '@reown/appkit/react'
import { useState } from 'react'
import { twMerge } from 'tailwind-merge'

const WalletDetailsPage = () => {
const { selectedWallet, isConnected } = useWallet()
const { open } = useAppKit()
const { disconnect } = useDisconnect()
const { focusedWallet, wallets } = useWalletStore()
const { isConnected } = useWallet()
const { username } = useAuth()
const [isBalanceHidden, setIsBalanceHidden] = useState(() => {
const prefs = getUserPreferences()
return prefs?.balanceHidden ?? false
})

const { username } = useAuth()
const isActiveWalletPW = selectedWallet?.walletProviderType === WalletProviderType.PEANUT
const isActiveWalletBYOW = selectedWallet?.walletProviderType === WalletProviderType.BYOW

console.log('selectedWallet', selectedWallet)
const walletDetails = wallets.find((wallet) => wallet.address === focusedWallet)

const handleToggleBalanceVisibility = (e: React.MouseEvent<HTMLButtonElement>) => {
e.stopPropagation()
Expand All @@ -46,11 +45,11 @@ const WalletDetailsPage = () => {
</div>

<div className="mx-auto">
{selectedWallet && (
{focusedWallet && walletDetails && (
<WalletCard
key={selectedWallet.address}
key={walletDetails.address}
type="wallet"
wallet={selectedWallet}
wallet={walletDetails}
username={username ?? ''}
selected
onClick={() => {}}
Expand All @@ -75,14 +74,14 @@ const WalletDetailsPage = () => {

<div
className={twMerge(
selectedWallet?.balances && !!selectedWallet?.balances?.length ? 'border-b border-b-n-1' : ''
walletDetails?.balances && !!walletDetails?.balances?.length ? 'border-b border-b-n-1' : ''
)}
>
{!!selectedWallet?.balances?.length ? (
{!!walletDetails?.balances?.length ? (
<div className="space-y-3">
<div className="text-base font-semibold">Balance</div>
<div>
{selectedWallet.balances.map((balance: IUserBalance) => (
{walletDetails.balances.map((balance: IUserBalance) => (
<ListItemView
key={`${balance.chainId}-${balance.symbol}`}
id={`${balance.chainId}-${balance.symbol}`}
Expand Down

0 comments on commit 3389e6d

Please sign in to comment.