From 7715c68228ef0d195c587f1a292483be45bbdc74 Mon Sep 17 00:00:00 2001 From: Aaron Pepper Date: Fri, 27 Dec 2024 14:23:16 +0100 Subject: [PATCH] added useEffect to airdrop auth hook --- .../Airdrop/AirdropGiftTracker/hooks/useAirdropAuth.ts | 6 +++--- .../AirdropGiftTracker/sections/LoggedOut/LoggedOut.tsx | 8 ++------ .../phase/Setup/components/AirdropLogin/AirdropLogin.tsx | 8 ++------ 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/containers/main/Airdrop/AirdropGiftTracker/hooks/useAirdropAuth.ts b/src/containers/main/Airdrop/AirdropGiftTracker/hooks/useAirdropAuth.ts index d5595af08..fc6dfef6a 100644 --- a/src/containers/main/Airdrop/AirdropGiftTracker/hooks/useAirdropAuth.ts +++ b/src/containers/main/Airdrop/AirdropGiftTracker/hooks/useAirdropAuth.ts @@ -1,4 +1,4 @@ -import { useCallback } from 'react'; +import { useCallback, useEffect } from 'react'; import { open } from '@tauri-apps/plugin-shell'; import { v4 as uuidv4 } from 'uuid'; import { useAirdropStore } from '@app/store/useAirdropStore'; @@ -22,7 +22,7 @@ export const useAirdropAuth = () => { [backendInMemoryConfig?.airdropTwitterAuthUrl] ); - const checkAuth = useCallback(() => { + useEffect(() => { if (authUuid && backendInMemoryConfig?.airdropApiUrl) { const interval = setInterval(() => { if (authUuid) { @@ -58,5 +58,5 @@ export const useAirdropAuth = () => { // eslint-disable-next-line react-hooks/exhaustive-deps }, [authUuid, backendInMemoryConfig?.airdropApiUrl]); - return { handleAuth, checkAuth }; + return { handleAuth }; }; diff --git a/src/containers/main/Airdrop/AirdropGiftTracker/sections/LoggedOut/LoggedOut.tsx b/src/containers/main/Airdrop/AirdropGiftTracker/sections/LoggedOut/LoggedOut.tsx index 7daec9e25..9ee44f047 100644 --- a/src/containers/main/Airdrop/AirdropGiftTracker/sections/LoggedOut/LoggedOut.tsx +++ b/src/containers/main/Airdrop/AirdropGiftTracker/sections/LoggedOut/LoggedOut.tsx @@ -1,6 +1,6 @@ import { GIFT_GEMS, useAirdropStore } from '@app/store/useAirdropStore'; import { ClaimButton, GemPill, Image, Title, Wrapper } from './styles'; -import { useEffect, useState } from 'react'; +import { useState } from 'react'; import ClaimModal from '../../components/ClaimModal/ClaimModal'; import { useTranslation } from 'react-i18next'; import gemImage from '../../images/gem.png'; @@ -11,11 +11,7 @@ export default function LoggedOut() { const { t } = useTranslation(['airdrop'], { useSuspense: false }); const { referralQuestPoints } = useAirdropStore(); - const { handleAuth, checkAuth } = useAirdropAuth(); - - useEffect(() => { - checkAuth(); - }, [checkAuth]); + const { handleAuth } = useAirdropAuth(); const gemsValue = (referralQuestPoints?.pointsForClaimingReferral || GIFT_GEMS).toLocaleString(); diff --git a/src/containers/phase/Setup/components/AirdropLogin/AirdropLogin.tsx b/src/containers/phase/Setup/components/AirdropLogin/AirdropLogin.tsx index 74f7cd910..2b373afaf 100644 --- a/src/containers/phase/Setup/components/AirdropLogin/AirdropLogin.tsx +++ b/src/containers/phase/Setup/components/AirdropLogin/AirdropLogin.tsx @@ -1,18 +1,14 @@ import { ClaimButton, Gem1, Gem2, Gem3, GemsWrapper, Text, TextWrapper, Title, Wrapper } from './styles'; import gemLargeImage from '../../../../main/Airdrop/AirdropGiftTracker/images/gem.png'; import { useTranslation } from 'react-i18next'; -import { useCallback, useEffect } from 'react'; +import { useCallback } from 'react'; import { useAppConfigStore } from '@app/store/useAppConfigStore'; import { useAirdropAuth } from '@app/containers/main/Airdrop/AirdropGiftTracker/hooks/useAirdropAuth'; export default function AirdropLogin() { const { t } = useTranslation(['airdrop'], { useSuspense: false }); const setAllowTelemetry = useAppConfigStore((s) => s.setAllowTelemetry); - const { handleAuth, checkAuth } = useAirdropAuth(); - - useEffect(() => { - checkAuth(); - }, [checkAuth]); + const { handleAuth } = useAirdropAuth(); const handleSubmit = useCallback( async (e: React.MouseEvent) => {