Skip to content

Commit

Permalink
added useEffect to airdrop auth hook
Browse files Browse the repository at this point in the history
  • Loading branch information
peps committed Dec 27, 2024
1 parent 368f464 commit 7715c68
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -22,7 +22,7 @@ export const useAirdropAuth = () => {
[backendInMemoryConfig?.airdropTwitterAuthUrl]
);

const checkAuth = useCallback(() => {
useEffect(() => {
if (authUuid && backendInMemoryConfig?.airdropApiUrl) {
const interval = setInterval(() => {
if (authUuid) {
Expand Down Expand Up @@ -58,5 +58,5 @@ export const useAirdropAuth = () => {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [authUuid, backendInMemoryConfig?.airdropApiUrl]);

return { handleAuth, checkAuth };
return { handleAuth };
};
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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();

Expand Down
Original file line number Diff line number Diff line change
@@ -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<HTMLButtonElement>) => {
Expand Down

0 comments on commit 7715c68

Please sign in to comment.