Skip to content

Commit

Permalink
add more lines
Browse files Browse the repository at this point in the history
  • Loading branch information
jorbuedo committed Sep 30, 2024
1 parent 0f14911 commit aa5cca0
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,7 @@ const PortfolioContext = React.createContext<PortfolioState & PortfolioActions>(
...defaultActions,
})

export const PortfolioProvider = ({
children,
initialState,
}: {
children: React.ReactNode
initialState?: Partial<PortfolioState>
}) => {
const useIsTokenHistoryApiAvailable = () => {
const {
networkManager: {tokenManager},
} = useSelectedNetwork()
Expand All @@ -78,7 +72,17 @@ export const PortfolioProvider = ({
return false
},
})
const isTokenHistoryApiAvailable = data ?? false
return data ?? false
}

export const PortfolioProvider = ({
children,
initialState,
}: {
children: React.ReactNode
initialState?: Partial<PortfolioState>
}) => {
const isTokenHistoryApiAvailable = useIsTokenHistoryApiAvailable()
const [portfolioState, dispatch] = React.useReducer(portfolioReducer, {...defaultState, ...initialState})

const actions = React.useRef<PortfolioActions>({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export const useGetPortfolioTokenChart = (
enabled: tokenInfo && isPrimaryToken(tokenInfo.info),
staleTime: time.oneMinute,
...options,
queryKey: ['useGetPortfolioTokenChart', '.', timeInterval, currency],
queryKey: ['useGetPortfolioTokenChart', 'pt', timeInterval, currency],
queryFn: async () => {
// force queryFn to be async, otherwise it takes longer and doesn't show isFetching
await delay(0)
Expand Down
28 changes: 16 additions & 12 deletions apps/wallet-mobile/src/kernel/query-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,23 @@ import {ptPriceQueryFn, TokenChartInterval} from '../features/Portfolio/common/h

const queryClient = new QueryClient()

Object.values(TokenChartInterval).forEach((TokenChartInterval) => {
queryClient.prefetchQuery<
Awaited<ReturnType<typeof ptPriceQueryFn>>,
Error,
Awaited<ReturnType<typeof ptPriceQueryFn>>,
['ptPriceHistory', TokenChartInterval]
>({
queryKey: ['ptPriceHistory', TokenChartInterval],
queryFn: ptPriceQueryFn,
cacheTime: Infinity,
staleTime: Infinity,
const prefetchPtPriceHistory = () => {
Object.values(TokenChartInterval).forEach((TokenChartInterval) => {
queryClient.prefetchQuery<
Awaited<ReturnType<typeof ptPriceQueryFn>>,
Error,
Awaited<ReturnType<typeof ptPriceQueryFn>>,
['ptPriceHistory', TokenChartInterval]
>({
queryKey: ['ptPriceHistory', TokenChartInterval],
queryFn: ptPriceQueryFn,
cacheTime: Infinity,
staleTime: Infinity,
})
})
})
}

prefetchPtPriceHistory()

const keyToPersist = 'persist'
/*
Expand Down

0 comments on commit aa5cca0

Please sign in to comment.