Skip to content

Commit 65a4051

Browse files
cs1707jinming0618hz002
authored
feat: modify the desktop page entry position & fix some bugs (#3277)
* fix: some bugs * feat: update dashboard * feat: revert block token btn * feat: revert assetlist popup dapp action * feat: condition show block token * chore * fix: desktop hidden block btn in token detail * feat: change popup height * feat: change open in tab button style --------- Co-authored-by: kim12322222 <[email protected]> Co-authored-by: hz002 <[email protected]>
1 parent 37eb402 commit 65a4051

File tree

23 files changed

+564
-113
lines changed

23 files changed

+564
-113
lines changed

_raw/locales/en/messages.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1865,7 +1865,8 @@
18651865
"addTestnet": "Network"
18661866
},
18671867
"noTestnetAssets": "No Custom Network Assets",
1868-
"addTokenEntryText": "Token"
1868+
"addTokenEntryText": "Token",
1869+
"openInTab": "Open in tab"
18691870
},
18701871
"hd": {
18711872
"howToConnectLedger": "How to Connect Ledger",

src/background/controller/wallet.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1629,6 +1629,9 @@ export class WalletController extends BaseController {
16291629
active: true,
16301630
url: url,
16311631
});
1632+
eventBus.emit(EVENTS.broadcastToUI, {
1633+
method: EVENTS.DESKTOP.FOCUSED,
1634+
});
16321635
const currentWindow = await Browser.windows.getLastFocused();
16331636
if (tab.windowId && tab.windowId !== currentWindow.id) {
16341637
Browser.windows.update(tab.windowId, {

src/constant/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,10 @@ export const EVENTS = {
562562
PERSIST_KEYRING: 'PERSIST_KEYRING',
563563

564564
RELOAD_ACCOUNT_LIST: 'RELOAD_ACCOUNT_LIST',
565+
566+
DESKTOP: {
567+
FOCUSED: 'DESKTOP_FOCUSED',
568+
},
565569
};
566570

567571
export const EVENTS_IN_BG = {

src/ui/component/DesktopSelectAccountList/styles.less

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
background-color: transparent;
44
width: 4px;
55
}
6+
::-webkit-scrollbar-track {
7+
margin: 10px 0; /* 模拟上下 padding */
8+
}
69
::-webkit-scrollbar-thumb {
710
background-color: var(--rb-neutral-line, #e0e5ec);
811
border-radius: 1000px;

src/ui/component/ExternalSwapBridgeDappPopup/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { ReactComponent as RcIconLink } from '@/ui/assets/link-cc.svg';
88
import { ReactComponent as RcIconMatchCC } from '@/ui/assets/match-cc.svg';
99

1010
import { Popup } from '@/ui/component';
11-
import { Skeleton } from 'antd';
11+
import { DrawerProps, Skeleton } from 'antd';
1212

1313
const isTab = getUiType().isTab;
1414
const getContainer = isTab ? '.js-rabby-popup-container' : undefined;
@@ -171,11 +171,13 @@ export const SwapBridgeDappPopup = ({
171171
onClose,
172172
dappList,
173173
loading,
174+
getContainer,
174175
}: {
175176
visible: boolean;
176177
onClose: () => void;
177178
dappList: SwapBridgeExternalDappInfo[];
178179
loading?: boolean;
180+
getContainer?: DrawerProps['getContainer'];
179181
}) => {
180182
const { t } = useTranslation();
181183
return (

src/ui/utils/portfolio/index.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ export const useQueryProjects = (
1313
withHistory = false,
1414
visible: boolean,
1515
isTestnet = false,
16-
isAll = false
16+
isAll = false,
17+
showBlocked = false
1718
) => {
1819
const [time, setTime] = useSafeState(dayjs().subtract(1, 'day'));
1920

@@ -37,7 +38,16 @@ export const useQueryProjects = (
3738
walletProject,
3839
customizeTokens,
3940
blockedTokens,
40-
} = useTokens(userAddr, historyTime, visible, 0, undefined, isTestnet, isAll);
41+
} = useTokens(
42+
userAddr,
43+
historyTime,
44+
visible,
45+
0,
46+
undefined,
47+
isTestnet,
48+
isAll,
49+
showBlocked
50+
);
4151

4252
const {
4353
data: portfolios,

src/ui/utils/portfolio/token.ts

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ export const useTokens = (
5959
isTestnet: boolean = chainServerId
6060
? !!findChain({ serverId: chainServerId })?.isTestnet
6161
: false,
62-
showAll = false
62+
showAll = false,
63+
showBlocked = false
6364
) => {
6465
const abortProcess = useRef<AbortController>();
6566
const [data, setData] = useSafeState(walletProject);
@@ -162,6 +163,16 @@ export const useTokens = (
162163
setData(_data);
163164
const snapshot = await queryTokensCache(userAddr, wallet, isTestnet);
164165

166+
const blocked = showBlocked
167+
? []
168+
: (await wallet.getBlockedToken()).filter((token) => {
169+
if (isTestnet) {
170+
return checkIsTestnet(token.chain);
171+
} else {
172+
return !checkIsTestnet(token.chain);
173+
}
174+
});
175+
165176
if (!snapshot) {
166177
log('--Terminate-tokens-snapshot-', userAddr);
167178
setLoading(false);
@@ -188,9 +199,11 @@ export const useTokens = (
188199
setData(_data);
189200
_tokens = sortWalletTokens(_data);
190201
if (isTestnet) {
191-
dispatch.account.setTestnetTokenList(filterDisplayToken(_tokens, []));
202+
dispatch.account.setTestnetTokenList(
203+
filterDisplayToken(_tokens, blocked)
204+
);
192205
} else {
193-
dispatch.account.setTokenList(filterDisplayToken(_tokens, []));
206+
dispatch.account.setTokenList(filterDisplayToken(_tokens, blocked));
194207
}
195208
setLoading(false);
196209
// setTokens(filterDisplayToken(_tokens, blocked));
@@ -239,9 +252,23 @@ export const useTokens = (
239252
// customize with balance
240253
customTokenList.push(token);
241254
}
255+
if (
256+
blocked.find(
257+
(t) =>
258+
isSameAddress(token.id, t.address) &&
259+
token.chain === t.chain &&
260+
token.is_core
261+
)
262+
) {
263+
blockedTokenList.push(token);
264+
}
242265
});
243266
const apiProvider = isTestnet ? wallet.testnetOpenapi : wallet.openapi;
244-
267+
const noBalanceBlockedTokens = blocked.filter((token) => {
268+
return !blockedTokenList.find(
269+
(t) => isSameAddress(token.address, t.id) && token.chain === t.chain
270+
);
271+
});
245272
const noBalanceCustomizeTokens = customizeTokens.filter((token) => {
246273
return !customTokenList.find(
247274
(t) => isSameAddress(token.address, t.id) && token.chain === t.chain
@@ -256,6 +283,13 @@ export const useTokens = (
256283
...noBalanceCustomTokens.filter((token) => !token.is_core)
257284
);
258285
}
286+
if (noBalanceBlockedTokens.length > 0) {
287+
const blockedTokens = await apiProvider.customListToken(
288+
noBalanceBlockedTokens.map((item) => `${item.chain}:${item.address}`),
289+
userAddr
290+
);
291+
blockedTokenList.push(...blockedTokens.filter((token) => token.is_core));
292+
}
259293
const formattedCustomTokenList = customTokenList.map(
260294
(token) => new DisplayedToken(token) as AbstractPortfolioToken
261295
);
@@ -286,12 +320,12 @@ export const useTokens = (
286320
_tokens = sortWalletTokens(_data);
287321
if (isTestnet) {
288322
dispatch.account.setTestnetTokenList([
289-
...filterDisplayToken(_tokens, []),
323+
...filterDisplayToken(_tokens, blocked),
290324
...formattedCustomTokenList,
291325
]);
292326
} else {
293327
dispatch.account.setTokenList([
294-
...filterDisplayToken(_tokens, []),
328+
...filterDisplayToken(_tokens, blocked),
295329
...formattedCustomTokenList,
296330
]);
297331
}

src/ui/views/Bridge/Component/BridgeContent.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,6 +676,7 @@ export const BridgeContent = () => {
676676
}}
677677
dappList={externalDapps}
678678
loading={externalDappsLoading}
679+
getContainer={getContainer}
679680
/>
680681
</div>
681682
) : null}

src/ui/views/CommonPopup/AssetList/AssetList.tsx

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useCommonPopupView } from '@/ui/utils';
1+
import { useCommonPopupView, useWallet } from '@/ui/utils';
22
import React, { useState, useRef, useEffect } from 'react';
33
import { ChainList } from './ChainList';
44
import { AssetListContainer } from './AssetListContainer';
@@ -14,6 +14,7 @@ import { Button } from 'antd';
1414
import { SpecialTokenListPopup } from './components/TokenButton';
1515
import { TestnetChainList } from './TestnetChainList';
1616
import { useFilteredTokens } from './useFilteredTokens';
17+
import { RcIconExternal1CC, RcIconExternalCC } from '@/ui/assets/dashboard';
1718

1819
export const AssetList = ({
1920
visible,
@@ -40,7 +41,7 @@ export const AssetList = ({
4041
const { isShowTestnet, selectedTab, onTabChange } = useSwitchNetTab();
4142

4243
React.useEffect(() => {
43-
setHeight(488);
44+
setHeight(500);
4445
}, []);
4546

4647
React.useEffect(() => {
@@ -60,6 +61,7 @@ export const AssetList = ({
6061

6162
const { sortedCustomize: tokens } = useFilteredTokens(selectChainId, false);
6263
const [showCustomizedTokens, setShowCustomizedTokens] = React.useState(false);
64+
const wallet = useWallet();
6365

6466
return (
6567
<div ref={containerRef}>
@@ -135,6 +137,34 @@ export const AssetList = ({
135137
onClose={onClose}
136138
/>
137139
</div>
140+
<footer className="h-[72px]">
141+
<div
142+
className={clsx(
143+
'fixed bottom-0 left-0 right-0 px-[20px] py-[14px]',
144+
'border-t-[0.5px] border-solid border-rabby-neutral-line',
145+
'bg-r-neutral-bg-2'
146+
)}
147+
>
148+
<button
149+
type="button"
150+
className={clsx(
151+
'w-full h-[44px] text-r-blue-default text-[15px] leading-[18px] font-medium',
152+
'rounded-[8px]',
153+
'border-[1px] border-solid border-rabby-blue-default',
154+
'bg-r-neutral-bg-2 hover:bg-r-blue-light1'
155+
)}
156+
onClick={() => {
157+
wallet.openInDesktop('/desktop/profile');
158+
window.close();
159+
}}
160+
>
161+
<div className="flex items-center justify-center gap-[4px]">
162+
{t('page.dashboard.assets.openInTab')}
163+
<RcIconExternalCC />
164+
</div>
165+
</button>
166+
</div>
167+
</footer>
138168
</div>
139169
);
140170
};

src/ui/views/CommonPopup/AssetList/CustomAssetList/AddCustomTokenPopup.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ export const AddCustomTokenPopup = ({ visible, onClose, onConfirm }: Props) => {
255255
<Popup
256256
visible={visible}
257257
closable={false}
258-
height={494}
258+
height={500}
259259
onClose={onClose}
260260
className="add-custom-token-popup"
261261
push={false}

0 commit comments

Comments
 (0)