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

fix: bridge show more #2623

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/ui/utils/portfolio/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ export class DisplayedToken implements AbstractPortfolioToken {
time_at: number;
price_24h_change?: number | null;
low_credit_score?: boolean;
raw_amount_hex_str?: string;
_amountStr?: string;
_priceStr?: string;
_amountChange?: number;
Expand Down Expand Up @@ -359,6 +360,7 @@ export class DisplayedToken implements AbstractPortfolioToken {
this.time_at = token.time_at;
this.price_24h_change = token.price_24h_change;
this.low_credit_score = token.low_credit_score;
this.raw_amount_hex_str = token.raw_amount_hex_str;

// 默认是它
this._usdValueChangeStr = '-';
Expand Down
1 change: 1 addition & 0 deletions src/ui/utils/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ export const abstractTokenToTokenItem = (
chain: token.chain,
amount: token.amount,
raw_amount: token.raw_amount,
raw_amount_hex_str: token.raw_amount_hex_str,
decimals: token.decimals,
display_symbol: token.display_symbol,
is_core: token.is_core,
Expand Down
4 changes: 4 additions & 0 deletions src/ui/views/Bridge/Component/BridgeContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,8 @@ export const BridgeContent = () => {
quoteLoading ||
!quoteList?.length;

const [showMoreOpen, setShowMoreOpen] = useState(false);

return (
<div
className={clsx(
Expand Down Expand Up @@ -393,6 +395,8 @@ export const BridgeContent = () => {
<div className="mx-20">
{selectedBridgeQuote && (
<BridgeShowMore
open={showMoreOpen}
setOpen={setShowMoreOpen}
sourceName={selectedBridgeQuote?.aggregator.name || ''}
sourceLogo={selectedBridgeQuote?.aggregator.logo_url || ''}
slippage={slippageState}
Expand Down
13 changes: 8 additions & 5 deletions src/ui/views/Bridge/Component/BridgeShowMore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ export const BridgeShowMore = ({
isCustomSlippage,
setAutoSlippage,
setIsCustomSlippage,
open,
setOpen,
}: {
open: boolean;
setOpen: Dispatch<SetStateAction<boolean>>;
openQuotesList: () => void;
sourceName: string;
sourceLogo: string;
Expand All @@ -57,7 +61,6 @@ export const BridgeShowMore = ({
setIsCustomSlippage: Dispatch<SetStateAction<boolean>>;
}) => {
const { t } = useTranslation();
const [show, setShow] = useState(false);

const data = useMemo(
() => tokenPriceImpact(fromToken, toToken, amount, toAmount),
Expand All @@ -66,7 +69,7 @@ export const BridgeShowMore = ({

useEffect(() => {
if ((!quoteLoading && data?.showLoss) || slippageError) {
setShow(true);
setOpen(true);
}
}, [quoteLoading, data?.showLoss]);

Expand All @@ -80,20 +83,20 @@ export const BridgeShowMore = ({
'cursor-pointer',
'text-r-neutral-foot text-12'
)}
onClick={() => setShow((e) => !e)}
onClick={() => setOpen((e) => !e)}
>
<span>{t('page.bridge.showMore.title')}</span>
<IconArrowDownCC
viewBox="0 0 14 14"
width={14}
height={14}
className={clsx('transition-transform', show && 'rotate-180')}
className={clsx('transition-transform', open && 'rotate-180')}
/>
</div>
<div className={clsx(dottedClassName)} />
</div>

<div className={clsx('overflow-hidden', !show && 'h-0')}>
<div className={clsx('overflow-hidden', !open && 'h-0')}>
{data?.showLoss && !quoteLoading && (
<div className="leading-4 mb-12 text-12 text-r-neutral-foot">
<div className="flex justify-between">
Expand Down
4 changes: 2 additions & 2 deletions src/ui/views/Bridge/hooks/token.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -253,15 +253,14 @@ export const useBridge = () => {
}
if (!quote?.manualClick) {
expiredTimer.current = setTimeout(() => {
// setRefreshId((e) => e + 1);
setRefreshId((e) => e + 1);
}, 1000 * 30);
}
setOriSelectedBridgeQuote(quote);
}, []);

useEffect(() => {
setQuotesList([]);
setSelectedBridgeQuote(undefined);
setRecommendFromToken(undefined);
}, [fromToken?.id, toToken?.id, fromChain, toChain, amount, inSufficient]);

Expand Down Expand Up @@ -484,6 +483,7 @@ export const useBridge = () => {
}
}
}
setSelectedBridgeQuote(undefined);
}, [
inSufficient,
aggregatorsList,
Expand Down
Loading