Skip to content

Commit

Permalink
Merge branch 'handleOptimizations'
Browse files Browse the repository at this point in the history
  • Loading branch information
HarshRajat committed Oct 22, 2024
2 parents 076f43b + 3c1deae commit 09a5c16
Show file tree
Hide file tree
Showing 19 changed files with 310 additions and 195 deletions.
3 changes: 3 additions & 0 deletions src/common/Common.baseLogos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@ export const walletTrackerLogo =

export const shapeShiftLogo =
'data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAAAQABAAD/4gIoSUNDX1BST0ZJTEUAAQEAAAIYAAAAAAQwAABtbnRyUkdCIFhZWiAAAAAAAAAAAAAAAABhY3NwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAQAA9tYAAQAAAADTLQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAlkZXNjAAAA8AAAAHRyWFlaAAABZAAAABRnWFlaAAABeAAAABRiWFlaAAABjAAAABRyVFJDAAABoAAAAChnVFJDAAABoAAAAChiVFJDAAABoAAAACh3dHB0AAAByAAAABRjcHJ0AAAB3AAAADxtbHVjAAAAAAAAAAEAAAAMZW5VUwAAAFgAAAAcAHMAUgBHAEIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFhZWiAAAAAAAABvogAAOPUAAAOQWFlaIAAAAAAAAGKZAAC3hQAAGNpYWVogAAAAAAAAJKAAAA+EAAC2z3BhcmEAAAAAAAQAAAACZmYAAPKnAAANWQAAE9AAAApbAAAAAAAAAABYWVogAAAAAAAA9tYAAQAAAADTLW1sdWMAAAAAAAAAAQAAAAxlblVTAAAAIAAAABwARwBvAG8AZwBsAGUAIABJAG4AYwAuACAAMgAwADEANv/bAEMABgQFBgUEBgYFBgcHBggKEAoKCQkKFA4PDBAXFBgYFxQ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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB/9k=';
15 changes: 9 additions & 6 deletions src/modules/rewards/components/BonusActivitiesItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { FC } from 'react';

// hooks
import { Activity, useGetRewardsActivity } from 'queries';
import { Activity, StakeActivityResponse, UsersActivity } from 'queries';
import { useAccount } from 'hooks';

// components
Expand All @@ -17,6 +17,9 @@ export type BonusActivitiesItemProps = {
isLoadingItem: boolean;
setErrorMessage: (errorMessage: string) => void;
isLocked: boolean;
allUsersActivity: StakeActivityResponse;
isAllActivitiesLoading: boolean;
refetchActivity: () => void;
};

const BonusActivitiesItem: FC<BonusActivitiesItemProps> = ({
Expand All @@ -25,12 +28,12 @@ const BonusActivitiesItem: FC<BonusActivitiesItemProps> = ({
isLoadingItem,
setErrorMessage,
isLocked,
allUsersActivity,
isAllActivitiesLoading,
refetchActivity,
}) => {
const {
data: usersSingleActivity,
isLoading,
refetch: refetchActivity,
} = useGetRewardsActivity({ userId, activityId: activity.id }, { enabled: !!userId });
const usersSingleActivity = allUsersActivity?.[activity?.activityType] as UsersActivity;
const isLoading = isAllActivitiesLoading;

const { isWalletConnected } = useAccount();

Expand Down
27 changes: 26 additions & 1 deletion src/modules/rewards/components/BonusActivitiesSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ import { FC, useState } from 'react';
import { css } from 'styled-components';

// hooks
import { useGetRewardsActivities, useGetUserRewardsDetails } from 'queries';
import {
StakeActivityResponse,
useGetRewardsActivities,
useGetRewardsActivity,
useGetUserRewardsDetails,
} from 'queries';
import { useAccount } from 'hooks';
import { useRewardsContext } from 'contexts/RewardsContext';

Expand Down Expand Up @@ -41,6 +46,23 @@ const BonusActivities: FC<BonusActivitiesSectionProps> = () => {

const { isLocked } = useRewardsContext();

// Combine all activities into a single array
const allActivities = [...bonusActivities];

// Extract the `activityType` from each activity and filter out any undefined values
const activityTypes = allActivities
.map((activity) => activity.activityType) // Extract `activityType`
.filter(Boolean); // Remove undefined/null values

const {
data: allUsersActivity,
isLoading: isAllActivitiesLoading,
refetch: refetchActivity,
} = useGetRewardsActivity(
{ userId: userDetails?.userId as string, activityTypes: activityTypes },
{ enabled: !!userDetails?.userId && activityTypes.length > 0 }
);

return (
<Box
display="flex"
Expand Down Expand Up @@ -82,6 +104,9 @@ const BonusActivities: FC<BonusActivitiesSectionProps> = () => {
isLoadingItem={isLoading}
setErrorMessage={setErrorMessage}
isLocked={isLocked}
allUsersActivity={allUsersActivity as StakeActivityResponse}
isAllActivitiesLoading={isAllActivitiesLoading}
refetchActivity={refetchActivity}
/>
))}
</Box>
Expand Down
17 changes: 11 additions & 6 deletions src/modules/rewards/components/DailyRewardsSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,19 @@ export type DailyRewardsSectionProps = {};
const DailyRewardsSection: FC<DailyRewardsSectionProps> = () => {
const [errorMessage, setErrorMessage] = useState('');

const { activeItem, activeDay, isActivityDisabled, isLoading, userDetails, dailyRewardsActivities, handleCheckIn } =
useDailyRewards();
const {
activeItem,
activeDay,
isActivityDisabled,
isLoading,
userDetails,
dailyRewardsActivities,
refetchSendActivities,
} = useDailyRewards();

const { isLocked } = useRewardsContext();

const isDailyRewardClaimed = useMemo(() => {
return isActivityDisabled && activeDay > 1 && userDetails;
}, [isActivityDisabled, activeDay, userDetails]);
const isDailyRewardClaimed = isActivityDisabled && activeDay > 1 && userDetails;

const displayDailyRewards = useMemo(() => {
return !isActivityDisabled && activeDay > 0 && activeItem && userDetails;
Expand Down Expand Up @@ -85,7 +90,7 @@ const DailyRewardsSection: FC<DailyRewardsSectionProps> = () => {
activityType={activeItem?.activityType as ActvityType}
userId={userDetails?.userId as string}
activityTypeId={activeItem?.id as string}
refetchActivity={() => handleCheckIn()}
refetchActivity={() => refetchSendActivities()}
setErrorMessage={setErrorMessage}
isLoadingActivity={false}
label="Check In"
Expand Down
34 changes: 33 additions & 1 deletion src/modules/rewards/components/RewardsActivitiesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ import { css } from 'styled-components';
import { Box, Lock, Text } from 'blocks';
import { useAccount } from 'hooks';
import { walletToCAIP10 } from 'helpers/w2w';
import { Activity, useGetRewardsActivities, useGetUserRewardsDetails } from 'queries';
import {
Activity,
StakeActivityResponse,
useGetRewardsActivities,
useGetRewardsActivity,
useGetUserRewardsDetails,
} from 'queries';
import { useRewardsContext } from 'contexts/RewardsContext';

import { RewardsActivitiesListItem } from './RewardsActivitiesListItem';
Expand Down Expand Up @@ -43,6 +49,23 @@ const RewardsActivitiesList: FC<RewardActivitiesProps> = () => {

const { isLocked } = useRewardsContext();

// Combine all activities into a single array
const allActivities = [...socialActivities, ...platformRewardActivities, ...channelSubscriptionActivities];

// Extract the `activityType` from each activity and filter out any undefined values
const activityTypes = allActivities
.map((activity) => activity.activityType) // Extract `activityType`
.filter(Boolean); // Remove undefined/null values

const {
data: allUsersActivity,
isLoading: isAllActivitiesLoading,
refetch: refetchActivity,
} = useGetRewardsActivity(
{ userId: userDetails?.userId as string, activityTypes: activityTypes },
{ enabled: !!userDetails?.userId && activityTypes.length > 0 }
);

return (
<Box
display="flex"
Expand All @@ -57,6 +80,9 @@ const RewardsActivitiesList: FC<RewardActivitiesProps> = () => {
activity={activity}
isLoadingItem={isLoading}
isLocked={isLocked}
allUsersActivity={allUsersActivity as StakeActivityResponse}
isAllActivitiesLoading={isAllActivitiesLoading}
refetchActivity={refetchActivity}
/>
))}
{(isLocked || !isWalletConnected) && (
Expand Down Expand Up @@ -103,6 +129,9 @@ const RewardsActivitiesList: FC<RewardActivitiesProps> = () => {
activity={activity}
isLoadingItem={isLoading}
isLocked={isLocked}
allUsersActivity={allUsersActivity as StakeActivityResponse}
isAllActivitiesLoading={isAllActivitiesLoading}
refetchActivity={refetchActivity}
/>
))}

Expand All @@ -114,6 +143,9 @@ const RewardsActivitiesList: FC<RewardActivitiesProps> = () => {
activity={activity}
isLoadingItem={isLoading}
isLocked={isLocked}
allUsersActivity={allUsersActivity as StakeActivityResponse}
isAllActivitiesLoading={isAllActivitiesLoading}
refetchActivity={refetchActivity}
/>
))}
</Box>
Expand Down
28 changes: 18 additions & 10 deletions src/modules/rewards/components/RewardsActivitiesListItem.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FC, useEffect, useMemo, useState } from 'react';

import { Activity, useGetRewardsActivity } from 'queries';
import { Activity, StakeActivityResponse, UsersActivity } from 'queries';
import { useAccount } from 'hooks';

import {
Expand All @@ -27,6 +27,9 @@ export type RewardActivitiesListItemProps = {
activity: Activity;
isLoadingItem: boolean;
isLocked: boolean;
allUsersActivity: StakeActivityResponse;
isAllActivitiesLoading: boolean;
refetchActivity: () => void;
};

const getUpdatedExpiryTime = (timestamp: number) => {
Expand All @@ -46,16 +49,16 @@ const RewardsActivitiesListItem: FC<RewardActivitiesListItemProps> = ({
activity,
isLoadingItem,
isLocked,
allUsersActivity,
isAllActivitiesLoading,
refetchActivity,
}) => {
const { isWalletConnected } = useAccount();
const {
data: usersSingleActivity,
isLoading,
refetch: refetchActivity,
} = useGetRewardsActivity({ userId, activityId: activity.id }, { enabled: !!userId });
const usersSingleActivity = allUsersActivity?.[activity?.activityType] as UsersActivity;
const isLoading = isAllActivitiesLoading;

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

const isRewardsLocked = useMemo(() => {
return (
Expand All @@ -68,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') {
handleLockStatus();
getLockStatus();
}
}, [usersSingleActivity?.status, activity.activityType]);
}, [usersSingleActivity?.status, activity.activityType, statusRecentActivities]);

return (
<Skeleton isLoading={isLoadingItem}>
Expand Down Expand Up @@ -247,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
13 changes: 12 additions & 1 deletion src/modules/rewards/components/RewardsActivityIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
PushAlpha,
CyberLogoRewards,
} from 'blocks';
import { quickSwapLogo, priceTrackerLogo, walletTrackerLogo, shapeShiftLogo } from 'common';
import { quickSwapLogo, priceTrackerLogo, walletTrackerLogo, shapeShiftLogo, revokeLogo } from 'common';
import { ActvityType } from 'queries';

type RewardsActivityIconProp = {
Expand Down Expand Up @@ -217,6 +217,17 @@ const RewardsActivityIcon: FC<RewardsActivityIconProp> = ({ type }) => {
);
}

if (type === 'channel_specific_subscriptions:REVOKE_NOTIFICATIONS_CHANNEL') {
return (
<img
width={48}
height={48}
src={revokeLogo}
style={{ borderRadius: 'var(--radius-round)' }}
/>
);
}

if (type === 'stake_1_uni_v2_lp_epoch' || type === 'stake_1k_push_epoch') {
return (
<StakePushGreyCoin
Expand Down
Loading

0 comments on commit 09a5c16

Please sign in to comment.