2023-04-21 07:23:27 -07:00
|
|
|
import { useWallet } from '@solana/wallet-adapter-react'
|
|
|
|
import { useNotifications } from './useNotifications'
|
|
|
|
import NotificationCookieStore from '@store/notificationCookieStore'
|
|
|
|
|
|
|
|
export function useIsAuthorized() {
|
2023-04-28 14:36:24 -07:00
|
|
|
const { publicKey, connected } = useWallet()
|
2023-04-21 07:23:27 -07:00
|
|
|
const { error, isFetched, isLoading } = useNotifications()
|
|
|
|
const token = NotificationCookieStore((s) => s.currentToken)
|
|
|
|
|
|
|
|
const isAuthorized =
|
2023-04-28 14:36:24 -07:00
|
|
|
publicKey?.toBase58() &&
|
|
|
|
token &&
|
|
|
|
!error &&
|
|
|
|
isFetched &&
|
|
|
|
!isLoading &&
|
|
|
|
connected
|
2023-04-21 07:23:27 -07:00
|
|
|
|
|
|
|
return isAuthorized
|
|
|
|
}
|