Skip to content

Commit d3676bd

Browse files
committed
fix: Launchdarkly flag added carousel-banners
1 parent 168bdf4 commit d3676bd

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

ui/components/multichain/account-overview/account-overview-layout.tsx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
import { Carousel } from '..';
1111
import {
1212
getAppIsLoading,
13+
getRemoteFeatureFlags,
1314
///: BEGIN:ONLY_INCLUDE_IF(solana)
1415
hasCreatedSolanaAccount,
1516
///: END:ONLY_INCLUDE_IF
@@ -41,6 +42,8 @@ export const AccountOverviewLayout = ({
4142
}: AccountOverviewLayoutProps) => {
4243
const dispatch = useDispatch();
4344
const isLoading = useSelector(getAppIsLoading);
45+
const remoteFeatureFlags = useSelector(getRemoteFeatureFlags);
46+
const isCarouselEnabled = Boolean(remoteFeatureFlags?.carouselBanners);
4447
const trackEvent = useContext(MetaMetricsContext);
4548
const [hasRendered, setHasRendered] = useState(false);
4649

@@ -54,7 +57,7 @@ export const AccountOverviewLayout = ({
5457
const [showDownloadMobileAppModal, setShowDownloadMobileAppModal] =
5558
useState(false);
5659

57-
const { slides } = useCarouselManagement();
60+
const { slides } = useCarouselManagement({ enabled: isCarouselEnabled });
5861

5962
const slideById = useMemo(() => {
6063
const m = new Map<string, CarouselSlide>();
@@ -124,13 +127,16 @@ export const AccountOverviewLayout = ({
124127
return (
125128
<>
126129
<div className="account-overview__balance-wrapper">{children}</div>
127-
<Carousel
128-
slides={slides}
129-
isLoading={isLoading}
130-
onClick={handleCarouselClick}
131-
onClose={handleRemoveSlide}
132-
onRenderSlides={handleRenderSlides}
133-
/>
130+
131+
{isCarouselEnabled && (
132+
<Carousel
133+
slides={slides}
134+
isLoading={isLoading}
135+
onClick={handleCarouselClick}
136+
onClose={handleRemoveSlide}
137+
onRenderSlides={handleRenderSlides}
138+
/>
139+
)}
134140
<AccountOverviewTabs {...tabsProps}></AccountOverviewTabs>
135141
{
136142
///: BEGIN:ONLY_INCLUDE_IF(solana)

ui/hooks/useCarouselManagement/useCarouselManagement.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
} from '../../selectors';
2020
import { fetchCarouselSlidesFromContentful } from './fetchCarouselSlidesFromContentful';
2121

22-
type UseSlideManagementProps = { testDate?: string };
22+
type UseSlideManagementProps = { testDate?: string; enabled?: boolean };
2323
const ZERO_BALANCE = '0x0';
2424

2525
export function isActive(
@@ -89,6 +89,7 @@ function orderByCardPlacement(slides: CarouselSlide[]): CarouselSlide[] {
8989

9090
export const useCarouselManagement = ({
9191
testDate,
92+
enabled = true,
9293
}: UseSlideManagementProps = {}) => {
9394
const inTest = Boolean(process.env.IN_TEST);
9495
const dispatch = useDispatch();
@@ -104,6 +105,15 @@ export const useCarouselManagement = ({
104105
);
105106

106107
useEffect(() => {
108+
// If carousel is disabled, clear the slides
109+
if (!enabled) {
110+
const empty: CarouselSlide[] = [];
111+
if (!isEqual(prevSlidesRef.current, empty)) {
112+
dispatch(updateSlides(empty));
113+
prevSlidesRef.current = empty;
114+
}
115+
return;
116+
}
107117
const maybeFetchContentful = async () => {
108118
const contentfulEnabled =
109119
remoteFeatureFlags?.contentfulCarouselEnabled ?? false;
@@ -198,6 +208,7 @@ export const useCarouselManagement = ({
198208
}
199209
})();
200210
}, [
211+
enabled,
201212
dispatch,
202213
hasZeroBalance,
203214
remoteFeatureFlags,

0 commit comments

Comments
 (0)