From 49e31fcac8ec6fa83a68fad8b93764684abb2b66 Mon Sep 17 00:00:00 2001 From: wenty22 Date: Fri, 6 Dec 2024 17:57:15 +0800 Subject: [PATCH] feat: Update token list sort rules --- .release/.changeset/eighty-clouds-jog.md | 5 ++++ .release/.changeset/pre.json | 1 + packages/canonical-bridge-widget/CHANGELOG.md | 6 ++++ packages/canonical-bridge-widget/package.json | 2 +- .../SelectModal/hooks/useTokenList.ts | 28 ++++--------------- 5 files changed, 18 insertions(+), 24 deletions(-) create mode 100644 .release/.changeset/eighty-clouds-jog.md diff --git a/.release/.changeset/eighty-clouds-jog.md b/.release/.changeset/eighty-clouds-jog.md new file mode 100644 index 00000000..d50b8e30 --- /dev/null +++ b/.release/.changeset/eighty-clouds-jog.md @@ -0,0 +1,5 @@ +--- +"@bnb-chain/canonical-bridge-widget": patch +--- + +Update token list sort rules diff --git a/.release/.changeset/pre.json b/.release/.changeset/pre.json index a2f4fa95..21a91838 100644 --- a/.release/.changeset/pre.json +++ b/.release/.changeset/pre.json @@ -6,6 +6,7 @@ "@bnb-chain/canonical-bridge-widget": "0.5.7" }, "changesets": [ + "eighty-clouds-jog", "light-emus-switch", "sharp-dryers-hear", "slimy-crabs-know" diff --git a/packages/canonical-bridge-widget/CHANGELOG.md b/packages/canonical-bridge-widget/CHANGELOG.md index 37efd502..6289a2d4 100644 --- a/packages/canonical-bridge-widget/CHANGELOG.md +++ b/packages/canonical-bridge-widget/CHANGELOG.md @@ -1,5 +1,11 @@ # @bnb-chain/canonical-bridge-widget +## 0.5.8-alpha.5 + +### Patch Changes + +- Update token list sort rules + ## 0.5.8-alpha.4 ### Patch Changes diff --git a/packages/canonical-bridge-widget/package.json b/packages/canonical-bridge-widget/package.json index eb4ef0ed..d9b42cba 100644 --- a/packages/canonical-bridge-widget/package.json +++ b/packages/canonical-bridge-widget/package.json @@ -1,6 +1,6 @@ { "name": "@bnb-chain/canonical-bridge-widget", - "version": "0.5.8-alpha.4", + "version": "0.5.8-alpha.5", "description": "canonical bridge widget", "author": "bnb-chain", "private": false, diff --git a/packages/canonical-bridge-widget/src/modules/aggregator/components/SelectModal/hooks/useTokenList.ts b/packages/canonical-bridge-widget/src/modules/aggregator/components/SelectModal/hooks/useTokenList.ts index d8276d7d..41fe26b8 100644 --- a/packages/canonical-bridge-widget/src/modules/aggregator/components/SelectModal/hooks/useTokenList.ts +++ b/packages/canonical-bridge-widget/src/modules/aggregator/components/SelectModal/hooks/useTokenList.ts @@ -38,28 +38,11 @@ export function useTokenList(tokens: IBridgeToken[] = [], keyword?: string) { const sortedTokens = sortTokens({ tokens: tmpTokens, orders: transferConfig.order?.tokens, - }) - .sort((a, b) => { - if (keyword) { - const isA = isChainOrTokenCompatible(a); - const isB = isChainOrTokenCompatible(b); - const findA = a.displaySymbol?.toLowerCase()?.includes(keyword?.toLowerCase()); - const findB = b.displaySymbol?.toLowerCase()?.includes(keyword?.toLowerCase()); - - if (findA && isA) { - return -1; - } - if (findB && isB) { - return 1; - } - } - return 0; - }) - .sort((a) => { - return isSameAddress(a.address, selectedToken?.address) && isChainOrTokenCompatible(a) - ? -1 - : 0; - }); + }).sort((a) => { + return isSameAddress(a.address, selectedToken?.address) && isChainOrTokenCompatible(a) + ? -1 + : 0; + }); return sortedTokens; }, [ @@ -68,7 +51,6 @@ export function useTokenList(tokens: IBridgeToken[] = [], keyword?: string) { getTokenBalance, getTokenPrice, selectedToken?.address, - keyword, ]); return { data: sortedTokens, isLoading: isLoadingTokenBalances || isLoadingTokenPrices };