Skip to content

Commit

Permalink
Login telegram if no connected address
Browse files Browse the repository at this point in the history
  • Loading branch information
teodorus-nathaniel committed Jun 28, 2024
1 parent 0da28a8 commit 3dc6032
Showing 1 changed file with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ import { useUpsertProfile } from '@/services/datahub/profiles/mutation'
import { getProfileQuery } from '@/services/datahub/profiles/query'
import { useSetReferrerId } from '@/services/datahub/referral/mutation'
import { augmentDatahubParams } from '@/services/datahub/utils'
import {
useMyAccount,
useMyGrillAddress,
useMyMainAddress,
} from '@/stores/my-account'
import { useMyAccount, useMyGrillAddress } from '@/stores/my-account'
import { useSubscriptionState } from '@/stores/subscription'
import { IdentityProvider as SDKIdentityProvider } from '@subsocial/data-hub-sdk'
import { useInitDataRaw } from '@tma.js/sdk-react'
Expand All @@ -27,7 +23,7 @@ type OnSuccess = (linkedIdentity: Identity) => void

const useLoginInTelegramMiniApps = () => {
const initData = useInitDataRaw(true)
const myAddress = useMyMainAddress()
const parentProxyAddress = useMyAccount((state) => state.parentProxyAddress)
const finalizeTemporaryAccount = useMyAccount.use.finalizeTemporaryAccount()

const data = initData?.result?.user
Expand Down Expand Up @@ -172,14 +168,14 @@ const useLoginInTelegramMiniApps = () => {
const isInitializedProxy = useMyAccount.use.isInitializedProxy()
useEffect(() => {
const login = async () => {
if (data && !myAddress && isInitializedProxy) {
if (data && !parentProxyAddress && isInitializedProxy) {
await loginTelegram()
}
}

login()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [data, myAddress, isInitializedProxy])
}, [data, parentProxyAddress, isInitializedProxy])

return { isLoading: isLoading, isSuccess: isSuccess }
}
Expand Down

0 comments on commit 3dc6032

Please sign in to comment.