Skip to content

Commit

Permalink
move Accordion into renderDetails to avoid rendering if no details ar…
Browse files Browse the repository at this point in the history
…e provided
  • Loading branch information
segun committed Aug 4, 2023
1 parent e33e442 commit 316e30c
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions app/components/UI/BlockaidBanner/BlockaidBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
import Icon from '../../../component-library/components/Icons/Icon/Icon';
import Text from '../../../component-library/components/Texts/Text/Text';
import { useStyles } from '../../../component-library/hooks/useStyles';
import { showBlockaidUI } from '../../../util/blockaid';
import AttributionLink from './AttributionLink';
import {
ATTRIBUTION_LINE_TEST_ID,
Expand All @@ -25,7 +26,6 @@ import {
} from './BlockaidBanner.constants';
import styleSheet from './BlockaidBanner.styles';
import { BlockaidBannerProps, FlagType, Reason } from './BlockaidBanner.types';
import { showBlockaidUI } from '../../../util/blockaid';

const getTitle = (reason: Reason): string => {
if (SUSPICIOUS_TITLED_REQUESTS.indexOf(reason) >= 0) {
Expand Down Expand Up @@ -78,13 +78,20 @@ const BlockaidBanner = (bannerProps: BlockaidBannerProps) => {

const renderDetails = () =>
features.length <= 0 ? null : (
<View style={styles.details}>
{features.map((feature, i) => (
<Text key={`feature-${i}`} style={styles.detailsItem}>
{feature}
</Text>
))}
</View>
<Accordion
title={strings('blockaid_banner.see_details')}
onPress={onToggleShowDetails}
isExpanded={false}
horizontalAlignment={AccordionHeaderHorizontalAlignment.Start}
>
<View style={styles.details}>
{features.map((feature, i) => (
<Text key={`feature-${i}`} style={styles.detailsItem}>
{feature}
</Text>
))}
</View>
</Accordion>
);

return (
Expand All @@ -98,14 +105,7 @@ const BlockaidBanner = (bannerProps: BlockaidBannerProps) => {
description={description}
{...bannerProps}
>
<Accordion
title={strings('blockaid_banner.see_details')}
onPress={onToggleShowDetails}
isExpanded={false}
horizontalAlignment={AccordionHeaderHorizontalAlignment.Start}
>
{renderDetails()}
</Accordion>
{renderDetails()}

<View style={styles.attributionBase}>
<View style={styles.attributionItem}>
Expand Down

0 comments on commit 316e30c

Please sign in to comment.