// Cached versions of the reads screens repeat on every visit. Each one goes // through queryCache under its own key; writes stay on `api` directly. import { api } from './client' import { KEYS, useQueryCache, type FetchOptions } from '../stores/queryCache' export function useCachedReads() { const cache = useQueryCache() return { me: (o?: FetchOptions) => cache.fetch(KEYS.profile, api.getMe, o), myOrders: (o?: FetchOptions) => cache.fetch(KEYS.orders, api.getMyOrders, o), accountingBalance: (o?: FetchOptions) => cache.fetch(KEYS.balance, api.getAccountingBalance, o), myLedgerEntries: (o?: FetchOptions) => cache.fetch(KEYS.ledger, api.getMyLedgerEntries, o), goldPrice: (o?: FetchOptions) => cache.fetch(KEYS.goldPrice, () => api.getLatestGoldPrice(), o), homeSlider: (o?: FetchOptions) => cache.fetch(KEYS.homeSlider, api.getHomeSlider, o), peek: cache.peek, invalidate: cache.invalidate, } }