diff --git a/apps/wallet-mobile/src/features/Portfolio/common/PortfolioProvider.tsx b/apps/wallet-mobile/src/features/Portfolio/common/PortfolioProvider.tsx index 1a339f5c34..0a1b1662ae 100644 --- a/apps/wallet-mobile/src/features/Portfolio/common/PortfolioProvider.tsx +++ b/apps/wallet-mobile/src/features/Portfolio/common/PortfolioProvider.tsx @@ -1,10 +1,6 @@ -import {invalid, isRight} from '@yoroi/common' -import {Portfolio} from '@yoroi/types' +import {invalid} from '@yoroi/common' import {produce} from 'immer' import * as React from 'react' -import {useQuery} from 'react-query' - -import {useSelectedNetwork} from '../../WalletManager/common/hooks/useSelectedNetwork' export const PortfolioDetailsTab = { Performance: 'Performance', @@ -36,7 +32,6 @@ const defaultActions: PortfolioActions = { } as const const defaultState: PortfolioState = { - isTokenHistoryApiAvailable: false, isPrimaryTokenActive: false, detailsTab: PortfolioDetailsTab.Overview, listTab: PortfolioListTab.Wallet, @@ -44,7 +39,6 @@ const defaultState: PortfolioState = { } as const type PortfolioState = { - isTokenHistoryApiAvailable: boolean isPrimaryTokenActive: boolean detailsTab: PortfolioDetailsTab listTab: PortfolioListTab @@ -56,25 +50,6 @@ const PortfolioContext = React.createContext( ...defaultActions, }) -const useIsTokenHistoryApiAvailable = () => { - const { - networkManager: {tokenManager}, - } = useSelectedNetwork() - const {data} = useQuery({ - queryKey: ['isTokenHistoryApiAvailable'], - initialData: () => false, - queryFn: async () => { - const response = await tokenManager.api.tokenHistory( - '279c909f348e533da5808898f87f9a14bb2c3dfbbacccd631d927a3f.534e454b', - Portfolio.Token.HistoryPeriod.OneDay, - ) - if (isRight(response)) return true - return false - }, - }) - return data ?? false -} - export const PortfolioProvider = ({ children, initialState, @@ -82,7 +57,6 @@ export const PortfolioProvider = ({ children: React.ReactNode initialState?: Partial }) => { - const isTokenHistoryApiAvailable = useIsTokenHistoryApiAvailable() const [portfolioState, dispatch] = React.useReducer(portfolioReducer, {...defaultState, ...initialState}) const actions = React.useRef({ @@ -102,8 +76,8 @@ export const PortfolioProvider = ({ }).current const context = React.useMemo( - () => ({...portfolioState, ...actions, isTokenHistoryApiAvailable}), - [actions, portfolioState, isTokenHistoryApiAvailable], + () => ({...portfolioState, ...actions}), + [actions, portfolioState], ) return {children} diff --git a/apps/wallet-mobile/src/features/Portfolio/useCases/PortfolioTokenDetails/PortfolioTokenDetailsScreen.tsx b/apps/wallet-mobile/src/features/Portfolio/useCases/PortfolioTokenDetails/PortfolioTokenDetailsScreen.tsx index 2de5c45759..82dc7a6cc3 100644 --- a/apps/wallet-mobile/src/features/Portfolio/useCases/PortfolioTokenDetails/PortfolioTokenDetailsScreen.tsx +++ b/apps/wallet-mobile/src/features/Portfolio/useCases/PortfolioTokenDetails/PortfolioTokenDetailsScreen.tsx @@ -1,4 +1,3 @@ -import {isPrimaryTokenInfo} from '@yoroi/portfolio' import {useTheme} from '@yoroi/theme' import {App} from '@yoroi/types' import * as React from 'react' @@ -24,14 +23,13 @@ import {PortfolioTokenInfo} from './PortfolioTokenInfo/PortfolioTokenInfo' export const PortfolioTokenDetailsScreen = () => { const strings = useStrings() - const {detailsTab, setDetailsTab, isTokenHistoryApiAvailable} = usePortfolio() + const {detailsTab, setDetailsTab} = usePortfolio() const {track} = useMetrics() const [isStickyTab, setIsStickyTab] = React.useState(false) const {id: tokenId} = usePortfolioTokenDetailParams() const {wallet} = useSelectedWallet() const tokenInfo = wallet.balances.records.get(tokenId)?.info - const isPrimaryToken = isPrimaryTokenInfo(tokenInfo) - const HEADER_HEIGHT = isPrimaryToken || isTokenHistoryApiAvailable ? 304 : 85 + const HEADER_HEIGHT = 304 const {styles} = useStyles(HEADER_HEIGHT) if (!tokenInfo) throwLoggedError(new App.Errors.InvalidState('Token info not found, invalid state')) @@ -92,13 +90,9 @@ export const PortfolioTokenDetailsScreen = () => { - {(isPrimaryToken || isTokenHistoryApiAvailable) && ( - <> - + - - - )} + {renderTabs}