({
query: ({ assetId }: { assetId?: string }) => ({
@@ -272,7 +280,8 @@ const kyberAIApi = createApi({
patchResult.undo()
}
},
- invalidatesTags: (result, error) => (error ? [] : ['watchlistsInfo', 'myWatchList']),
+ invalidatesTags: (result, error) =>
+ error ? [] : [RTK_QUERY_TAGS.GET_WATCHLIST_INFO_KYBER_AI, RTK_QUERY_TAGS.GET_WATCHLIST_TOKENS_KYBER_AI],
}),
//20.
removeFromWatchlist: builder.mutation({
@@ -301,7 +310,8 @@ const kyberAIApi = createApi({
patchResult.undo()
}
},
- invalidatesTags: (_, error) => (error ? [] : ['watchlistsInfo', 'myWatchList']),
+ invalidatesTags: (_, error) =>
+ error ? [] : [RTK_QUERY_TAGS.GET_WATCHLIST_INFO_KYBER_AI, RTK_QUERY_TAGS.GET_WATCHLIST_TOKENS_KYBER_AI],
}),
//21.
createCustomWatchlist: builder.mutation({
@@ -310,7 +320,7 @@ const kyberAIApi = createApi({
method: 'POST',
params,
}),
- invalidatesTags: (_, error) => (error ? [] : ['watchlistsInfo']),
+ invalidatesTags: (_, error) => (error ? [] : [RTK_QUERY_TAGS.GET_WATCHLIST_INFO_KYBER_AI]),
}),
//22.
deleteCustomWatchlist: builder.mutation({
@@ -319,7 +329,8 @@ const kyberAIApi = createApi({
method: 'DELETE',
params,
}),
- invalidatesTags: (_, error) => (error ? [] : ['watchlistsInfo', 'myWatchList']),
+ invalidatesTags: (_, error) =>
+ error ? [] : [RTK_QUERY_TAGS.GET_WATCHLIST_INFO_KYBER_AI, RTK_QUERY_TAGS.GET_WATCHLIST_TOKENS_KYBER_AI],
}),
//23.
updateWatchlistsName: builder.mutation({
@@ -351,7 +362,7 @@ const kyberAIApi = createApi({
await dispatch(kyberAIApi.endpoints.createCustomWatchlist.initiate({ name: t`My 1st Watchlists` }))
}
},
- providesTags: ['watchlistsInfo'],
+ providesTags: [RTK_QUERY_TAGS.GET_WATCHLIST_INFO_KYBER_AI],
}),
//26.
updateCustomizedWatchlistsPriorities: builder.mutation({
@@ -360,7 +371,7 @@ const kyberAIApi = createApi({
method: 'PUT',
params: { orderedIds },
}),
- invalidatesTags: ['watchlistsInfo'],
+ invalidatesTags: [RTK_QUERY_TAGS.GET_WATCHLIST_INFO_KYBER_AI],
}),
getFilterCategories: builder.query<{ displayName: string; queryKey: string; values: SelectOption[] }[], void>({
query: () => ({
diff --git a/src/pages/TrueSightV2/hooks/useRenderRankingList.tsx b/src/pages/TrueSightV2/hooks/useRenderRankingList.tsx
index 94de308a97..89a49d7b38 100644
--- a/src/pages/TrueSightV2/hooks/useRenderRankingList.tsx
+++ b/src/pages/TrueSightV2/hooks/useRenderRankingList.tsx
@@ -502,7 +502,7 @@ const renderByColumnType: Record<
<>
{['Binance', 'OKX', 'Bybit'].map((exname: string) => {
const exchange = token?.fundingRateExtra?.uMarginList?.find((item: any) => item.exchangeName === exname)
- const rate = (exchange && exchange.rate) || 0
+ const rate = exchange?.rate || 0
return (
{rate.toFixed(4) + '%' || '--'}
diff --git a/src/services/kyberAISubscription.ts b/src/services/kyberAISubscription.ts
index 42e7a7f3e8..460d3f21e2 100644
--- a/src/services/kyberAISubscription.ts
+++ b/src/services/kyberAISubscription.ts
@@ -39,5 +39,10 @@ const kyberAIApi = createApi({
}),
})
-export const { useGetParticipantInfoQuery, useRequestWhiteListMutation, useLazyCheckReferralCodeQuery } = kyberAIApi
+export const {
+ useLazyGetParticipantInfoQuery,
+ useGetParticipantInfoQuery,
+ useRequestWhiteListMutation,
+ useLazyCheckReferralCodeQuery,
+} = kyberAIApi
export default kyberAIApi
diff --git a/src/state/profile/hooks.ts b/src/state/profile/hooks.ts
index 720b203025..6afdb1c52d 100644
--- a/src/state/profile/hooks.ts
+++ b/src/state/profile/hooks.ts
@@ -5,7 +5,6 @@ import { useSelector } from 'react-redux'
import { useGetOrCreateProfileMutation } from 'services/identity'
import { useActiveWeb3React } from 'hooks'
-import kyberAIapi from 'pages/TrueSightV2/hooks/useKyberAIData'
import { AppState } from 'state'
import { useSessionInfo } from 'state/authen/hooks'
import { UserProfile, authenActions } from 'state/authen/reducer'
@@ -229,7 +228,6 @@ export const useSaveUserProfile = () => {
account: string | undefined
}) => {
dispatch(authenActions.updateProfile({ profile, isAnonymous }))
- dispatch(kyberAIapi.util.invalidateTags(['myWatchList']))
saveCacheProfile({
isAnonymous,
profile,
diff --git a/src/state/user/hooks.tsx b/src/state/user/hooks.tsx
index c7b303230e..a859d904e3 100644
--- a/src/state/user/hooks.tsx
+++ b/src/state/user/hooks.tsx
@@ -1,7 +1,7 @@
import { ChainId, Token } from '@kyberswap/ks-sdk-core'
import { useCallback, useMemo } from 'react'
import { useDispatch, useSelector } from 'react-redux'
-import { useGetParticipantInfoQuery } from 'services/kyberAISubscription'
+import { useGetParticipantInfoQuery, useLazyGetParticipantInfoQuery } from 'services/kyberAISubscription'
import { SUGGESTED_BASES } from 'constants/bases'
import { TERM_FILES_PATH } from 'constants/index'
@@ -509,11 +509,16 @@ export const useIsWhiteListKyberAI = () => {
currentData: rawData,
isFetching,
isError,
- refetch,
} = useGetParticipantInfoQuery(undefined, {
skip: !userInfo || userInfo?.data?.hasAccessToKyberAI,
})
+ const [getParticipantInfoQuery] = useLazyGetParticipantInfoQuery()
+ // why not use refetch of useGetParticipantInfoQuery: loop api issues, idk.
+ const refetch = useCallback(() => {
+ userInfo && getParticipantInfoQuery()
+ }, [getParticipantInfoQuery, userInfo])
+
const { account } = useActiveWeb3React()
const [connectingWallet] = useIsConnectingWallet()
|