Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wow-sven committed Oct 20, 2023
1 parent 0f7b730 commit 646282f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
1 change: 0 additions & 1 deletion dashboard/src/@core/components/session/SessionGuard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ interface Props {
const AuthDialog: React.FC<Props> = ({ open, onReqAuthorize, onLogout }) => {
const [scope, setScope] = useState<Array<string>>(['0x1::*::*', '0x3::*::*'])
const [maxInactiveInterval, setMaxInactiveInterval] = useState<number>(1200)

const handleAuth = () => {
onReqAuthorize && onReqAuthorize(scope, maxInactiveInterval)
}
Expand Down
16 changes: 8 additions & 8 deletions dashboard/src/context/auth/AuthContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,9 @@ const AuthProvider = ({ children }: Props) => {
const rooch = useRooch()

// ** States
const [defaultAccount, setDefaultAccount] = useState<AccountDataType | null>(() => {
if (defaultProvider.accounts && defaultProvider.accounts.size > 0) {
return defaultProvider.accounts.values().next().value
}

return null
})
const [defaultAccount, setDefaultAccount] = useState<AccountDataType | null>(
defaultProvider.defaultAccount,
)

const [accounts, setAccounts] = useState<Map<string, AccountDataType> | null>(
defaultProvider.accounts,
Expand Down Expand Up @@ -294,7 +290,11 @@ const AuthProvider = ({ children }: Props) => {
}

const getDefaultAccount = (): AccountDataType | null => {
return defaultAccount ?? metamask.accounts.length > 0
if (defaultAccount) {
return defaultAccount
}

return metamask.accounts.length > 0
? {
roochAddress: metamask.accounts[0],
address: metamask.accounts[0],
Expand Down

0 comments on commit 646282f

Please sign in to comment.