fad06fd
import type { ReactNode } from 'react'
import { alovaInstance } from '@/shared/api'
import { ThemeProvider } from '@/shared/theme'
import { ApiErrorGate } from './api-error-gate'
/**
* App-wide providers (Redux / QueryClient / theme / auth context, ...).
*
* Alova is provider-less, so the only wiring here is instance configuration.
* Keeping provider composition here lets `app/index.tsx` stay pure bootstrap.
*/
/**
* Alova caches GET responses in memory for 5 minutes by default and this app
* has no cache-invalidation layer (useAsync refetches on mount/route change).
* Without this, a mutation such as creating a space keeps rendering the list
* cached before the POST, so the new row never appears until a tab reload.
* Disabling GET response caching fixes every list; concurrent identical
* requests are still deduplicated by shareRequest.
*/
alovaInstance.options.cacheFor = { GET: 0 }
export function AppProviders({ children }: { children: ReactNode }) {
// The outage gate is deliberately above the router: it is a property of the
// transport, not of any single route, and it must be able to swallow the
// whole tree (auth screens included) without touching the URL.
return (
<ApiErrorGate>
<ThemeProvider>
{children}
</ThemeProvider>
</ApiErrorGate>
)
}