Skip to content

Commit

Permalink
tweak remote promo sheet logic
Browse files Browse the repository at this point in the history
  • Loading branch information
walmat committed Oct 25, 2023
1 parent 2da3c89 commit a8eef90
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/components/remote-promo-sheet/RemotePromoSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ export function RemotePromoSheet() {
}}
items={items.map((item: any) => {
if (item.gradient) {
console.log(item.gradient);
if (item.gradient.includes('.')) {
const gradient = get(colors, item.gradient);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ export const hasNonZeroAssetBalance = async (
ethereumUtils
.getNativeAssetForNetwork(network, accountAddress)
.then(nativeAsset => Number(nativeAsset?.balance?.amount) > 0)
.catch(error => {
console.error(`Failed to get balance for network ${network}: ${error}`);
.catch(() => {
return false;
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@ import store from '@/redux/store';

export const hasSelectedWallet = (): boolean => {
const { selected } = store.getState().wallets;

console.log({ selected });
return !!selected;
};
8 changes: 7 additions & 1 deletion src/components/remote-promo-sheet/useRunCampaignChecks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { logger } from '@/logger';
import { PromoSheet } from '@/graphql/__generated__/arc';

import * as fns from './check-fns';
import { REMOTE_PROMO_SHEETS, useExperimentalFlag } from '@/config';

const TIMEOUT_BETWEEN_PROMOS = 5 * 60 * 1000; // 5 minutes in milliseconds

Expand Down Expand Up @@ -49,6 +50,8 @@ const timeBetweenPromoSheets = () => {
};

export const useRunCampaignChecks = () => {
const remotePromoSheets = useExperimentalFlag(REMOTE_PROMO_SHEETS);

const isPromoCurrentlyShown = mmkv.getBoolean(
STORAGE_IDS.PROMO_CURRENTLY_SHOWN
);
Expand All @@ -57,6 +60,7 @@ export const useRunCampaignChecks = () => {
{},
{
enabled:
remotePromoSheets &&
!isPromoCurrentlyShown &&
timeBetweenPromoSheets() >= TIMEOUT_BETWEEN_PROMOS,
}
Expand All @@ -81,7 +85,7 @@ export const runCampaignChecks = async (

const campaignPromises = (campaigns?.items || [])
.filter((campaign): campaign is PromoSheet => campaign !== null)
.map(async campaign => shouldPromptCampaign(campaign));
.map(async campaign => await shouldPromptCampaign(campaign));

// In order to save computational bandwidth, we will resolve with the first campaign that should be shown, disregarding all others
const result = await resolveFirstRejectLast(campaignPromises);
Expand Down Expand Up @@ -155,6 +159,8 @@ export const shouldPromptCampaign = async (
}
);

console.log({ shouldPrompt, campaignKey });

// If any action check returns false, shouldPrompt will be false, so we won't show it.
// Otherwise, if all action checks pass, we will show the promo to the user
return shouldPrompt ? { campaignId: id, campaignKey } : undefined;
Expand Down

0 comments on commit a8eef90

Please sign in to comment.