Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug bash fixes #5237

Merged
merged 12 commits into from
Dec 8, 2023
3 changes: 2 additions & 1 deletion src/helpers/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,8 @@ export const getFormattedTimeQuantity = (
ms: number,
maxUnits?: number
): string => {
const totalMinutes = Math.ceil(ms / (1000 * 60));
const totalSeconds = ms / 1000;
const totalMinutes = Math.ceil(totalSeconds / 60);
const totalHours = Math.floor(totalMinutes / 60);
const days = Math.floor(totalHours / 24);
const hours = totalHours % 24;
Expand Down
2 changes: 1 addition & 1 deletion src/languages/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -1270,7 +1270,7 @@
"error": "Oops!\nPlease pull to refresh.",
"points": "points",
"referral_code_copied": "Referral code copied",
"earn_points_for_referring": "Earn points for referring friends once they swap $100 through Rainbow"
"earn_points_for_referring": "Earn points when your referrals swap $100 through Rainbow, plus earn 10% of the points your referrals earn"
},
"console": {
"claim_bonus_paragraph": "You'll receive an additional 100 points once you swap at least $100 through Rainbow",
Expand Down
2 changes: 1 addition & 1 deletion src/resources/points.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export function usePoints({ walletAddress }: { walletAddress: string }) {

useEffect(() => {
const nextDistribution = query?.data?.points?.meta?.distribution?.next;
if (nextDistribution && Date.now() / 1000 > nextDistribution) {
if (nextDistribution && Date.now() >= nextDistribution * 1000) {
query.refetch();
}
}, [query]);
Expand Down
1 change: 0 additions & 1 deletion src/screens/SignTransactionSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1654,7 +1654,6 @@ const SimulationCard = ({
simulationError,
]);

console.log({ simulationScanResult });
return (
<FadedScrollCard
cardHeight={cardHeight}
Expand Down
4 changes: 3 additions & 1 deletion src/screens/points/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ export const buildTwitterIntentMessage = (
let text = rainbows;
text += encodeURIComponent('\n\n');
text += encodeURIComponent(
`I just had ${ONBOARDING_TOTAL_POINTS} Rainbow Points dropped into my wallet — plus an extra ${METAMASK_POINTS} Points as a bonus for migrating my MetaMask wallet into Rainbow`
`I just had ${
ONBOARDING_TOTAL_POINTS - METAMASK_POINTS
} Rainbow Points dropped into my wallet — plus an extra ${METAMASK_POINTS} Points as a bonus for migrating my MetaMask wallet into Rainbow`
);
text += `🦊${encodeURIComponent(' ')}🔫`;
text += encodeURIComponent('\n\n');
Expand Down
3 changes: 1 addition & 2 deletions src/screens/points/content/PointsContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ export default function PointsContent() {
// onPress={() => {}}
title={i18n.t(i18n.l.points.points.next_drop)}
mainText={getFormattedTimeQuantity(
nextDistributionSeconds,
nextDistributionSeconds * 1000 - Date.now(),
2
)}
icon="􀉉"
Expand Down Expand Up @@ -537,7 +537,6 @@ export default function PointsContent() {
message: referralUrl,
}
: {
message: referralUrl,
url: referralUrl,
}
);
Expand Down
4 changes: 2 additions & 2 deletions src/screens/points/content/ReferralContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { haptics } from '@/utils';
import { delay } from '@/utils/delay';
import { useFocusEffect } from '@react-navigation/native';
import React, { useCallback, useEffect, useState } from 'react';
import { Keyboard, TextInput } from 'react-native';
import { InteractionManager, Keyboard, TextInput } from 'react-native';
import Animated, {
useAnimatedStyle,
useSharedValue,
Expand Down Expand Up @@ -97,7 +97,7 @@ export default function ReferralContent() {

useFocusEffect(
useCallback(() => {
delay(400).then(() => textInputRef.current?.focus());
delay(600).then(() => textInputRef.current?.focus());

return () => {
setReferralCodeDisplay('');
Expand Down
63 changes: 41 additions & 22 deletions src/screens/points/content/console/calculate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ export const Calculate = () => {
const { accountENS, accountAddress } = useAccountProfile();

const [isCalculationComplete, setIsCalculationComplete] = useState(false);
const [shouldShowContinueButton, setShouldShowContinueButton] = useState(
false
);

const accountName = (abbreviateEnsForDisplay(accountENS, 10) ||
formatAddress(accountAddress, 4, 5)) as string;
Expand Down Expand Up @@ -132,24 +135,30 @@ export const Calculate = () => {
typingSpeed={100}
/>
</Line>
<Line alignHorizontal="justify">
<AnimatedText
color={rainbowColors.red}
delayStart={1000}
enableHapticTyping
textContent={`${i18n.t(i18n.l.points.console.metamask_swaps)}:`}
/>
<AnimatedText
color={rainbowColors.red}
delayStart={1000}
enableHapticTyping
textAlign="right"
textContent={`$${abbreviateNumber(
metamaskSwaps?.data?.usd_amount ?? 0
)}`}
typingSpeed={100}
/>
</Line>
{metamaskSwaps?.data?.usd_amount ? (
<Line alignHorizontal="justify">
<AnimatedText
color={rainbowColors.red}
delayStart={1000}
enableHapticTyping
textContent={`${i18n.t(
i18n.l.points.console.metamask_swaps
)}:`}
/>
<AnimatedText
color={rainbowColors.red}
delayStart={1000}
enableHapticTyping
textAlign="right"
textContent={`$${abbreviateNumber(
metamaskSwaps?.data?.usd_amount ?? 0
)}`}
typingSpeed={100}
/>
</Line>
) : (
<></>
)}
<Line alignHorizontal="justify">
<AnimatedText
color={rainbowColors.purple}
Expand All @@ -162,7 +171,10 @@ export const Calculate = () => {
delayStart={1000}
enableHapticTyping
onComplete={() => {
setIsCalculationComplete(true);
const complete = setTimeout(() => {
setIsCalculationComplete(true);
}, 500);
return () => clearTimeout(complete);
}}
textAlign="right"
textContent={`+ ${bonus?.earnings?.total}`}
Expand Down Expand Up @@ -195,14 +207,17 @@ export const Calculate = () => {
textContent={(
profile?.onboardPoints?.user.onboarding?.earnings?.total ?? 0
).toLocaleString('en-US')}
onComplete={() => {
setShouldShowContinueButton(true);
}}
typingSpeed={100}
/>
</Line>
</Paragraph>
</Stack>

<AnimatePresence
condition={isCalculationComplete && !!profile}
condition={shouldShowContinueButton && !!profile}
duration={300}
>
<Bleed horizontal={{ custom: 14 }}>
Expand Down Expand Up @@ -276,15 +291,19 @@ export const Calculate = () => {
color={textColors.gray}
delayStart={1000}
onComplete={() => {
setIsCalculationComplete(true);
const complete = setTimeout(() => {
setIsCalculationComplete(true);
setShouldShowContinueButton(true);
}, 500);
return () => clearTimeout(complete);
}}
weight="normal"
multiline
textContent={i18n.t(i18n.l.points.console.claim_bonus_paragraph)}
/>
</Stack>
<AnimatePresence
condition={isCalculationComplete && !!profile}
condition={shouldShowContinueButton && !!profile}
duration={300}
>
<Bleed horizontal={{ custom: 14 }}>
Expand Down
11 changes: 9 additions & 2 deletions src/screens/points/content/console/review.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const Review = () => {
)}`}
/>
</Paragraph>
{shareBonusPoints && (
{shareBonusPoints ? (
<Line alignHorizontal="justify">
<AnimatedText
color={textColors.account}
Expand All @@ -68,6 +68,8 @@ export const Review = () => {
textContent={`+ ${shareBonusPoints}`}
/>
</Line>
) : (
<></>
)}
<Paragraph>
<AnimatedText
Expand All @@ -90,7 +92,12 @@ export const Review = () => {
/>
<AnimatedText
color={textColors.gray}
onComplete={() => setShowDoneButton(true)}
onComplete={() => {
const complete = setTimeout(() => {
setShowDoneButton(true);
}, 500);
return () => clearTimeout(complete);
}}
textContent={i18n.t(
i18n.l.points.console.share_bonus_paragraph_three
)}
Expand Down
5 changes: 4 additions & 1 deletion src/screens/points/content/console/share.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,10 @@ export const Share = () => {
color={textColors.account}
delayStart={1000}
onComplete={() => {
setShowShareButtons(true);
const complete = setTimeout(() => {
setShowShareButtons(true);
}, 500);
return () => clearTimeout(complete);
}}
weight="normal"
multiline
Expand Down
2 changes: 1 addition & 1 deletion src/screens/points/contexts/PointsProfileContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export const PointsProfileProvider = ({
});
}
}
if (!points) {
if (!points || !points.onboardPoints) {
logger.error(new RainbowError('Error onboarding points user'), {
referralCode,
challenge,
Expand Down
Loading