Skip to content

Commit

Permalink
update locked status
Browse files Browse the repository at this point in the history
  • Loading branch information
corlard3y committed Oct 22, 2024
1 parent e6165c7 commit 3c1deae
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
11 changes: 8 additions & 3 deletions src/modules/rewards/components/RewardsActivitiesListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const RewardsActivitiesListItem: FC<RewardActivitiesListItemProps> = ({
const isLoading = isAllActivitiesLoading;

const [errorMessage, setErrorMessage] = useState('');
const { getLockStatus } = useLockedStatus();
const { refetchRecentActivities, getLockStatus, statusRecentActivities } = useLockedStatus();

const isRewardsLocked = useMemo(() => {
return (
Expand All @@ -71,12 +71,17 @@ const RewardsActivitiesListItem: FC<RewardActivitiesListItemProps> = ({
const isNotDiscordOrTwitter =
activity.activityType !== 'follow_push_on_discord' && activity.activityType !== 'follow_push_on_twitter';

const updateActivities = () => {
refetchActivity();
refetchRecentActivities();
};

// if activityType is twitter or discord, then re-call check lock status fn
useEffect(() => {
if (activity.activityType == 'follow_push_on_discord' || activity.activityType == 'follow_push_on_twitter') {
getLockStatus();
}
}, [usersSingleActivity, activity.activityType]);
}, [usersSingleActivity?.status, activity.activityType, statusRecentActivities]);

return (
<Skeleton isLoading={isLoadingItem}>
Expand Down Expand Up @@ -250,7 +255,7 @@ const RewardsActivitiesListItem: FC<RewardActivitiesListItemProps> = ({
userId={userId}
activityTypeId={activity.id}
activityType={activity.activityType}
refetchActivity={refetchActivity}
refetchActivity={() => updateActivities()}
setErrorMessage={setErrorMessage}
usersSingleActivity={usersSingleActivity}
isLoadingActivity={isLoading}
Expand Down
8 changes: 6 additions & 2 deletions src/modules/rewards/hooks/useLockedStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ const useLockedStatus = () => {
const caip10WalletAddress = walletToCAIP10({ account });
const { data: userDetails, status, error } = useGetUserRewardsDetails({ caip10WalletAddress });

const { data: sendRecentActivities } = useGetRewardActivityStatus(
const {
data: sendRecentActivities,
refetch: refetchRecentActivities,
status: statusRecentActivities,
} = useGetRewardActivityStatus(
{
userId: userDetails?.userId as string,
activities: ['follow_push_on_discord', 'follow_push_on_twitter'],
Expand Down Expand Up @@ -60,7 +64,7 @@ const useLockedStatus = () => {
}
}, [userDetails?.userId, isWalletConnected, account, status]);

return { getLockStatus };
return { getLockStatus, refetchRecentActivities, statusRecentActivities };
};

export default useLockedStatus;

0 comments on commit 3c1deae

Please sign in to comment.