From 5a2d01327695499e2f43ea6011d6cf8a2981342a Mon Sep 17 00:00:00 2001 From: XiaoYhun Date: Tue, 26 Sep 2023 10:08:11 +0700 Subject: [PATCH 1/6] try fix chain param issue --- src/hooks/web3/useSyncNetworkParamWithStore.ts | 14 ++++++-------- src/pages/TrueSightV2/components/NetworkSelect.tsx | 1 - src/pages/TrueSightV2/hooks/useKyberAIData.tsx | 2 ++ 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/hooks/web3/useSyncNetworkParamWithStore.ts b/src/hooks/web3/useSyncNetworkParamWithStore.ts index 1b24eb12ec..b6ab8d067b 100644 --- a/src/hooks/web3/useSyncNetworkParamWithStore.ts +++ b/src/hooks/web3/useSyncNetworkParamWithStore.ts @@ -21,7 +21,7 @@ export function useSyncNetworkParamWithStore() { const tried = triedEager.current useEffect(() => { - if (!paramChainId) { + if (!networkParam || !paramChainId) { triedSync.current = true return } @@ -36,16 +36,14 @@ export function useSyncNetworkParamWithStore() { */ ;(async () => { if (triedSync.current) return - triedSync.current = true setRequestingNetwork(networkParam) await changeNetwork(paramChainId, undefined, () => { - if (networkParam) { - navigate( - { ...location, pathname: location.pathname.replace(networkParam, networkInfo.route) }, - { replace: true }, - ) - } + navigate( + { ...location, pathname: location.pathname.replace(networkParam, networkInfo.route) }, + { replace: true }, + ) }) + triedSync.current = true })() }, [changeNetwork, location, navigate, networkInfo.route, networkParam, paramChainId, tried]) diff --git a/src/pages/TrueSightV2/components/NetworkSelect.tsx b/src/pages/TrueSightV2/components/NetworkSelect.tsx index d85924efcd..25864a03be 100644 --- a/src/pages/TrueSightV2/components/NetworkSelect.tsx +++ b/src/pages/TrueSightV2/components/NetworkSelect.tsx @@ -60,7 +60,6 @@ const DropdownItem = styled(Row)` ` const NetworkSelect = ({ filter, setFilter }: { filter?: string; setFilter: (c?: string) => void }) => { - console.log('🚀 ~ file: NetworkSelect.tsx:63 ~ NetworkSelect ~ filter:', filter) const theme = useTheme() const [isShowOptions, setIsShowOptions] = useState(false) diff --git a/src/pages/TrueSightV2/hooks/useKyberAIData.tsx b/src/pages/TrueSightV2/hooks/useKyberAIData.tsx index 7f28e3e64a..6b16322d33 100644 --- a/src/pages/TrueSightV2/hooks/useKyberAIData.tsx +++ b/src/pages/TrueSightV2/hooks/useKyberAIData.tsx @@ -57,6 +57,7 @@ const kyberAIApi = createApi({ }, providesTags: (result, error, arg) => (arg.watchlist === true ? ['myWatchList', 'tokenList'] : ['tokenList']), }), + //2. addToWatchlist: builder.mutation({ query: (params: { tokenAddress: string; chain: string }) => ({ url: `/watchlist`, @@ -65,6 +66,7 @@ const kyberAIApi = createApi({ }), invalidatesTags: (res, err, params) => [{ type: 'tokenOverview', id: params.tokenAddress }, 'myWatchList'], }), + //3. removeFromWatchlist: builder.mutation({ query: (params: { tokenAddress: string; chain: string }) => ({ url: `/watchlist`, From c301e6a7ae9959b04057ffefcf2d3cd60e919d9e Mon Sep 17 00:00:00 2001 From: XiaoYhun Date: Tue, 26 Sep 2023 10:12:27 +0700 Subject: [PATCH 2/6] remove account checks for watchlist button --- src/pages/TrueSightV2/components/table/index.tsx | 1 - src/pages/TrueSightV2/pages/SingleToken.tsx | 2 +- src/pages/TrueSightV2/pages/TokenAnalysisList.tsx | 1 - 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/pages/TrueSightV2/components/table/index.tsx b/src/pages/TrueSightV2/components/table/index.tsx index 61b88974ae..f3d3444fd8 100644 --- a/src/pages/TrueSightV2/components/table/index.tsx +++ b/src/pages/TrueSightV2/components/table/index.tsx @@ -627,7 +627,6 @@ const WidgetTokenRow = ({ const handleWatchlistClick = (e: any) => { e.stopPropagation() - if (!account) return setLoadingStar(true) if (isWatched) { mixpanelHandler(MIXPANEL_TYPE.KYBERAI_ADD_TOKEN_TO_WATCHLIST, { diff --git a/src/pages/TrueSightV2/pages/SingleToken.tsx b/src/pages/TrueSightV2/pages/SingleToken.tsx index 0d55268d6f..f14304273c 100644 --- a/src/pages/TrueSightV2/pages/SingleToken.tsx +++ b/src/pages/TrueSightV2/pages/SingleToken.tsx @@ -262,7 +262,7 @@ const TokenNameGroup = ({ token, isLoading }: { token?: IAssetOverview; isLoadin const [isWatched, setIsWatched] = useState(false) const handleStarClick = () => { - if (!token || !chain || !address || !account) return + if (!token || !chain || !address) return if (isWatched) { mixpanelHandler(MIXPANEL_TYPE.KYBERAI_ADD_TOKEN_TO_WATCHLIST, { token_name: token.symbol?.toUpperCase(), diff --git a/src/pages/TrueSightV2/pages/TokenAnalysisList.tsx b/src/pages/TrueSightV2/pages/TokenAnalysisList.tsx index 91b60f8b62..4e8e61fcab 100644 --- a/src/pages/TrueSightV2/pages/TokenAnalysisList.tsx +++ b/src/pages/TrueSightV2/pages/TokenAnalysisList.tsx @@ -501,7 +501,6 @@ const TokenRow = React.memo(function TokenRow({ const handleWatchlistClick = (e: any) => { e.stopPropagation() - if (!account) return setLoadingStar(true) if (isWatched) { mixpanelHandler(MIXPANEL_TYPE.KYBERAI_ADD_TOKEN_TO_WATCHLIST, { From a7ff923d1a14dc4592296c3f0d9f007c596a9db0 Mon Sep 17 00:00:00 2001 From: XiaoYhun Date: Tue, 26 Sep 2023 10:13:11 +0700 Subject: [PATCH 3/6] fix warning --- src/pages/TrueSightV2/components/table/index.tsx | 2 -- src/pages/TrueSightV2/pages/SingleToken.tsx | 2 -- src/pages/TrueSightV2/pages/TokenAnalysisList.tsx | 2 -- 3 files changed, 6 deletions(-) diff --git a/src/pages/TrueSightV2/components/table/index.tsx b/src/pages/TrueSightV2/components/table/index.tsx index f3d3444fd8..3d0974102a 100644 --- a/src/pages/TrueSightV2/components/table/index.tsx +++ b/src/pages/TrueSightV2/components/table/index.tsx @@ -19,7 +19,6 @@ import AnimatedLoader from 'components/Loader/AnimatedLoader' import Pagination from 'components/Pagination' import Row, { RowFit } from 'components/Row' import { APP_PATHS } from 'constants/index' -import { useActiveWeb3React } from 'hooks' import { MIXPANEL_TYPE, useMixpanelKyberAI } from 'hooks/useMixpanel' import { useOnClickOutside } from 'hooks/useOnClickOutside' import useTheme from 'hooks/useTheme' @@ -589,7 +588,6 @@ const WidgetTokenRow = ({ }) => { const theme = useTheme() const navigate = useNavigate() - const { account } = useActiveWeb3React() const mixpanelHandler = useMixpanelKyberAI() const reachedMaxLimit = useIsReachMaxLimitWatchedToken(token?.tokens.length) diff --git a/src/pages/TrueSightV2/pages/SingleToken.tsx b/src/pages/TrueSightV2/pages/SingleToken.tsx index f14304273c..b6a9ec5a55 100644 --- a/src/pages/TrueSightV2/pages/SingleToken.tsx +++ b/src/pages/TrueSightV2/pages/SingleToken.tsx @@ -14,7 +14,6 @@ import Column from 'components/Column' import Icon from 'components/Icons/Icon' import Row, { RowBetween, RowFit } from 'components/Row' import { APP_PATHS } from 'constants/index' -import { useActiveWeb3React } from 'hooks' import { MIXPANEL_TYPE, useMixpanelKyberAI } from 'hooks/useMixpanel' import useTheme from 'hooks/useTheme' import { PROFILE_MANAGE_ROUTES } from 'pages/NotificationCenter/const' @@ -249,7 +248,6 @@ const TokenDescription = ({ description }: { description: string }) => { } const TokenNameGroup = ({ token, isLoading }: { token?: IAssetOverview; isLoading?: boolean }) => { - const { account } = useActiveWeb3React() const theme = useTheme() const mixpanelHandler = useMixpanelKyberAI() const navigate = useNavigate() diff --git a/src/pages/TrueSightV2/pages/TokenAnalysisList.tsx b/src/pages/TrueSightV2/pages/TokenAnalysisList.tsx index 4e8e61fcab..16d50fb1b8 100644 --- a/src/pages/TrueSightV2/pages/TokenAnalysisList.tsx +++ b/src/pages/TrueSightV2/pages/TokenAnalysisList.tsx @@ -20,7 +20,6 @@ import Row, { RowBetween, RowFit } from 'components/Row' import { MouseoverTooltipDesktopOnly } from 'components/Tooltip' import { APP_PATHS, ICON_ID } from 'constants/index' import { NETWORKS_INFO } from 'constants/networks' -import { useActiveWeb3React } from 'hooks' import { MIXPANEL_TYPE, useMixpanelKyberAI } from 'hooks/useMixpanel' import { useOnClickOutside } from 'hooks/useOnClickOutside' import useTheme from 'hooks/useTheme' @@ -475,7 +474,6 @@ const TokenRow = React.memo(function TokenRow({ const navigate = useNavigate() const location = useLocation() const mixpanelHandler = useMixpanelKyberAI() - const { account } = useActiveWeb3React() const theme = useTheme() const reachedMaxLimit = useIsReachMaxLimitWatchedToken() const [showSwapMenu, setShowSwapMenu] = useState(false) From 2eb7f20ac3694d683b9709a4f54818f2bdbf289e Mon Sep 17 00:00:00 2001 From: XiaoYhun Date: Tue, 26 Sep 2023 10:24:03 +0700 Subject: [PATCH 4/6] fit min height for list --- src/pages/TrueSightV2/pages/TokenAnalysisList.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pages/TrueSightV2/pages/TokenAnalysisList.tsx b/src/pages/TrueSightV2/pages/TokenAnalysisList.tsx index 16d50fb1b8..f16b3ccb95 100644 --- a/src/pages/TrueSightV2/pages/TokenAnalysisList.tsx +++ b/src/pages/TrueSightV2/pages/TokenAnalysisList.tsx @@ -50,12 +50,15 @@ const TableWrapper = styled.div` border-bottom: none; transition: all 0.15s ease; overflow: hidden; + min-height: 500px; + background-color: ${({ theme }) => theme.background}; @media only screen and (max-width: 1080px) { margin-left: -16px; margin-right: -16px; border-radius: 0px; border: none; overflow-x: scroll; + min-height: 250px; } ` const PaginationWrapper = styled.div` @@ -66,6 +69,8 @@ const PaginationWrapper = styled.div` overflow: hidden; min-height: 50px; background-color: ${({ theme }) => theme.background}; + border-top: 1px solid ${({ theme }) => theme.border}; + @media only screen and (max-width: 1080px) { margin-left: -16px; margin-right: -16px; @@ -988,7 +993,7 @@ export default function TokenAnalysisList() { ) : ( - + Date: Tue, 26 Sep 2023 13:19:18 +0700 Subject: [PATCH 5/6] fix bug price chart get wrong chain address --- src/pages/TrueSightV2/components/chart/datafeed.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/TrueSightV2/components/chart/datafeed.tsx b/src/pages/TrueSightV2/components/chart/datafeed.tsx index 4772508182..b398d79c35 100644 --- a/src/pages/TrueSightV2/components/chart/datafeed.tsx +++ b/src/pages/TrueSightV2/components/chart/datafeed.tsx @@ -12,6 +12,7 @@ import { } from 'components/TradingViewChart/charting_library' import { getTradingViewTimeZone } from 'components/TradingViewChart/utils' import { DEFAULT_EXPLORE_PAGE_TOKEN } from 'pages/TrueSightV2/constants' +import useKyberAIAssetOverview from 'pages/TrueSightV2/hooks/useKyberAIAssetOverview' import { useLazyChartingDataQuery } from 'pages/TrueSightV2/hooks/useKyberAIData' import { IAssetOverview, OHLCData } from 'pages/TrueSightV2/types' @@ -21,7 +22,7 @@ const configurationData = { export const useDatafeed = (isBTC: boolean, token?: IAssetOverview) => { const intervalRef = useRef() - const { chain, address } = useParams() + const { chain, address } = useKyberAIAssetOverview() const [getChartingData, { isLoading }] = useLazyChartingDataQuery() useEffect(() => { return () => { From 5d510bbdb8280a94c21536b2c480bbf0afa14dc3 Mon Sep 17 00:00:00 2001 From: XiaoYhun Date: Tue, 26 Sep 2023 13:43:42 +0700 Subject: [PATCH 6/6] fix fail --- src/pages/TrueSightV2/components/chart/datafeed.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/pages/TrueSightV2/components/chart/datafeed.tsx b/src/pages/TrueSightV2/components/chart/datafeed.tsx index b398d79c35..f2afcaf88f 100644 --- a/src/pages/TrueSightV2/components/chart/datafeed.tsx +++ b/src/pages/TrueSightV2/components/chart/datafeed.tsx @@ -1,5 +1,4 @@ import { useEffect, useMemo, useRef } from 'react' -import { useParams } from 'react-router-dom' import { ErrorCallback,