Skip to content

Commit

Permalink
rm optimal
Browse files Browse the repository at this point in the history
  • Loading branch information
lendihop committed Dec 23, 2024
1 parent 35c95f8 commit 0fe329e
Show file tree
Hide file tree
Showing 15 changed files with 4 additions and 297 deletions.
34 changes: 0 additions & 34 deletions src/app/hooks/use-load-partners-promo.ts

This file was deleted.

4 changes: 0 additions & 4 deletions src/app/pages/Home/OtherComponents/Tokens/Tokens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import clsx from 'clsx';
import { SyncSpinner, Divider, Checkbox } from 'app/atoms';
import DropdownWrapper from 'app/atoms/DropdownWrapper';
import { useAppEnv } from 'app/env';
import { useLoadPartnersPromo } from 'app/hooks/use-load-partners-promo';
import { useTokensListingLogic } from 'app/hooks/use-tokens-listing-logic';
import { ReactComponent as EditingIcon } from 'app/icons/editing.svg';
import { ReactComponent as SearchIcon } from 'app/icons/search.svg';
Expand All @@ -21,7 +20,6 @@ import { ButtonForManageDropdown } from 'app/templates/ManageDropdown';
import { PartnersPromotion, PartnersPromotionVariant } from 'app/templates/partners-promotion';
import SearchAssetField from 'app/templates/SearchAssetField';
import { setTestID } from 'lib/analytics';
import { OptimalPromoVariantEnum } from 'lib/apis/optimal';
import { TEZ_TOKEN_SLUG, TEMPLE_TOKEN_SLUG } from 'lib/assets';
import { useEnabledAccountTokensSlugs } from 'lib/assets/hooks';
import { RECENT_TERMS_VERSION } from 'lib/constants';
Expand Down Expand Up @@ -118,8 +116,6 @@ export const TokensTab = memo(() => {
return tokensJsx;
}, [filteredAssets, activeAssetSlug, publicKeyHash, mainnetTokensScamSlugsRecord]);

useLoadPartnersPromo(OptimalPromoVariantEnum.Token);

useEffect(() => {
if (activeIndex !== 0 && activeIndex >= filteredAssets.length) {
setActiveIndex(0);
Expand Down
12 changes: 0 additions & 12 deletions src/app/store/partners-promotion/actions.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,10 @@
import { createAction } from '@reduxjs/toolkit';

import { OptimalPromotionType, OptimalPromoVariantEnum } from 'lib/apis/optimal';
import { createActions } from 'lib/store';

interface HidePromotionActionPayload {
id: string;
timestamp: number;
}

export const loadPartnersPromoAction = createActions<
{
optimalPromoVariantEnum: OptimalPromoVariantEnum;
accountAddress: string;
},
OptimalPromotionType,
string
>('partnersPromo/LOAD_PARTNERS');

export const togglePartnersPromotionAction = createAction<boolean>('partnersPromo/TOGGLE_PARTNERS_PROMO');

export const hidePromotionAction = createAction<HidePromotionActionPayload>('advertising/PROMOTION_HIDING');
22 changes: 0 additions & 22 deletions src/app/store/partners-promotion/epics.ts

This file was deleted.

16 changes: 2 additions & 14 deletions src/app/store/partners-promotion/reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,12 @@ import { persistReducer } from 'redux-persist';
import hardSet from 'redux-persist/lib/stateReconciler/hardSet';

import { AD_HIDING_TIMEOUT } from 'lib/constants';
import { createEntity, storageConfig } from 'lib/store';
import { storageConfig } from 'lib/store';

import { hidePromotionAction, loadPartnersPromoAction, togglePartnersPromotionAction } from './actions';
import { hidePromotionAction, togglePartnersPromotionAction } from './actions';
import { partnersPromotionInitialState, PartnersPromotionState } from './state';

const partnersPromotionReducer = createReducer(partnersPromotionInitialState, builder => {
builder.addCase(loadPartnersPromoAction.submit, state => ({
...state,
promotion: createEntity(state.promotion.data, true)
}));
builder.addCase(loadPartnersPromoAction.success, (state, { payload }) => ({
...state,
promotion: createEntity(payload, false)
}));
builder.addCase(loadPartnersPromoAction.fail, (state, { payload }) => ({
...state,
promotion: createEntity(state.promotion.data, false, payload)
}));
builder.addCase(togglePartnersPromotionAction, (state, { payload }) => ({
...state,
shouldShowPromotion: payload,
Expand Down
2 changes: 0 additions & 2 deletions src/app/store/partners-promotion/selectors.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { useSelector } from '..';

export const usePartnersPromoSelector = () => useSelector(state => state.partnersPromotion.promotion);

export const useShouldShowPartnersPromoSelector = () =>
useSelector(({ partnersPromotion }) => partnersPromotion.shouldShowPromotion);

Expand Down
23 changes: 1 addition & 22 deletions src/app/store/partners-promotion/state.mock.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,8 @@
import { createEntity, mockPersistedState } from 'lib/store';
import { mockPersistedState } from 'lib/store';

import type { PartnersPromotionState } from './state';

export const mockPartnersPromotion = {
body: '',
campaign_type: '',
copy: {
headline: '',
cta: '',
content: ''
},
display_type: '',
div_id: '',
html: [],
id: '',
image: '',
link: '',
nonce: '',
text: '',
view_time_url: '',
view_url: ''
};

export const mockPartnersPromotionState = mockPersistedState<PartnersPromotionState>({
promotion: createEntity(mockPartnersPromotion),
shouldShowPromotion: true,
promotionHidingTimestamps: {}
});
7 changes: 0 additions & 7 deletions src/app/store/partners-promotion/state.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import { OptimalPromotionType } from 'lib/apis/optimal';
import { LoadableEntityState, createEntity } from 'lib/store';

import { mockPartnersPromotion } from './state.mock';

export interface PartnersPromotionState {
promotion: LoadableEntityState<OptimalPromotionType>;
shouldShowPromotion: boolean;
promotionHidingTimestamps: StringRecord<number>;
}

export const partnersPromotionInitialState: PartnersPromotionState = {
promotion: createEntity(mockPartnersPromotion),
shouldShowPromotion: false,
promotionHidingTimestamps: {}
};
2 changes: 0 additions & 2 deletions src/app/store/root-state.epics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { buyWithCreditCardEpics } from './buy-with-credit-card/epics';
import { collectiblesEpics } from './collectibles/epics';
import { collectiblesMetadataEpics } from './collectibles-metadata/epics';
import { currencyEpics } from './currency/epics';
import { partnersPromotionEpics } from './partners-promotion/epics';
import type { RootState } from './root-state.type';
import { swapEpics } from './swap/epics';
import { tokensMetadataEpics } from './tokens-metadata/epics';
Expand All @@ -22,7 +21,6 @@ const allEpics = combineEpics(
advertisingEpics,
notificationsEpics,
swapEpics,
partnersPromotionEpics,
balancesEpics,
assetsEpics,
tokensMetadataEpics,
Expand Down
2 changes: 0 additions & 2 deletions src/app/templates/activity/Activity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import InfiniteScroll from 'react-infinite-scroll-component';

import { SyncSpinner } from 'app/atoms';
import { useAppEnv } from 'app/env';
import { useLoadPartnersPromo } from 'app/hooks/use-load-partners-promo';
import { ReactComponent as LayersIcon } from 'app/icons/layers.svg';
import { useShouldShowPartnersPromoSelector } from 'app/store/partners-promotion/selectors';
import { PartnersPromotion, PartnersPromotionVariant } from 'app/templates/partners-promotion';
Expand All @@ -32,7 +31,6 @@ export const ActivityComponent: React.FC<Props> = ({ assetSlug }) => {
const { publicKeyHash: accountAddress } = useAccount();

const shouldShowPartnersPromo = useShouldShowPartnersPromoSelector();
useLoadPartnersPromo();

const promotion = useMemo(() => {
if (shouldShowPartnersPromo)
Expand Down

This file was deleted.

16 changes: 1 addition & 15 deletions src/app/templates/partners-promotion/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import { postAdImpression } from 'lib/apis/ads-api';
import { AD_HIDING_TIMEOUT } from 'lib/constants';

import { HypelabPromotion } from './components/hypelab-promotion';
import { OptimalPromotion } from './components/optimal-promotion';
import { PersonaPromotion } from './components/persona-promotion';
import styles from './partners-promotion.module.css';
import { PartnersPromotionVariant } from './types';
Expand Down Expand Up @@ -48,7 +47,7 @@ export const PartnersPromotion = memo<PartnersPromotionProps>(({ variant, id, pa
const isAnalyticsSentRef = useRef(false);

const [isHiddenTemporarily, setIsHiddenTemporarily] = useState(shouldBeHiddenTemporarily(hiddenAt));
const [providerName, setProviderName] = useState<AdsProviderLocalName>('Optimal');
const [providerName, setProviderName] = useState<AdsProviderLocalName>('HypeLab');
const [adError, setAdError] = useState(false);
const [adIsReady, setAdIsReady] = useState(false);

Expand Down Expand Up @@ -85,7 +84,6 @@ export const PartnersPromotion = memo<PartnersPromotionProps>(({ variant, id, pa
[id, dispatch]
);

const handleOptimalError = useCallback(() => setProviderName('HypeLab'), []);
const handleHypelabError = useCallback(
() => (withPersonaProvider ? setProviderName('Persona') : setAdError(true)),
[withPersonaProvider]
Expand All @@ -107,18 +105,6 @@ export const PartnersPromotion = memo<PartnersPromotionProps>(({ variant, id, pa
>
{(() => {
switch (providerName) {
case 'Optimal':
return (
<OptimalPromotion
variant={variant}
isVisible={adIsReady}
pageName={pageName}
onAdRectSeen={handleAdRectSeen}
onClose={handleClosePartnersPromoClick}
onReady={handleAdReady}
onError={handleOptimalError}
/>
);
case 'HypeLab':
return (
<HypelabPromotion
Expand Down
1 change: 0 additions & 1 deletion src/lib/ads/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export enum AdsProviderTitle {
Optimal = 'Optimal',
HypeLab = 'HypeLab',
Persona = 'Persona',
Temple = 'Temple Wallet'
Expand Down
Loading

0 comments on commit 0fe329e

Please sign in to comment.