Disables batching for i18n query (#3181)
* Disables batching for i18n query * Makes i18n batch skip explicitpull/3432/head
parent
ef36a93a55
commit
df3e3e8237
|
@ -6,6 +6,11 @@ import { trpc } from "@lib/trpc";
|
|||
export function useViewerI18n() {
|
||||
return trpc.useQuery(["viewer.public.i18n"], {
|
||||
staleTime: Infinity,
|
||||
/**
|
||||
* i18n should never be clubbed with other queries, so that it's caching can be managed independently.
|
||||
* We intend to not cache i18n query
|
||||
**/
|
||||
context: { skipBatch: true },
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,11 @@ type AppPropsWithChildren = AppProps & {
|
|||
};
|
||||
|
||||
const CustomI18nextProvider = (props: AppPropsWithChildren) => {
|
||||
const { i18n, locale } = trpc.useQuery(["viewer.public.i18n"]).data ?? {
|
||||
/**
|
||||
* i18n should never be clubbed with other queries, so that it's caching can be managed independently.
|
||||
* We intend to not cache i18n query
|
||||
**/
|
||||
const { i18n, locale } = trpc.useQuery(["viewer.public.i18n"], { context: { skipBatch: true } }).data ?? {
|
||||
locale: "en",
|
||||
};
|
||||
|
||||
|
|
|
@ -85,9 +85,7 @@ export default withTRPC<AppRouter>({
|
|||
splitLink({
|
||||
// check for context property `skipBatch`
|
||||
condition: (op) => {
|
||||
// i18n should never be clubbed with other queries, so that it's caching can be managed independently
|
||||
// We intend to not cache i18n query
|
||||
return op.context.skipBatch === true || op.path === "viewer.public.i18n";
|
||||
return op.context.skipBatch === true;
|
||||
},
|
||||
// when condition is true, use normal request
|
||||
true: httpLink({ url }),
|
||||
|
|
|
@ -501,7 +501,11 @@ function SettingsView(props: ComponentProps<typeof Settings> & { localeProp: str
|
|||
);
|
||||
}
|
||||
|
||||
const WithQuery = withQuery(["viewer.public.i18n"]);
|
||||
/**
|
||||
* i18n should never be clubbed with other queries, so that it's caching can be managed independently.
|
||||
* We intend to not cache i18n query
|
||||
**/
|
||||
const WithQuery = withQuery(["viewer.public.i18n"], { context: { skipBatch: true } });
|
||||
|
||||
export default function Settings(props: Props) {
|
||||
const { t } = useLocale();
|
||||
|
|
Loading…
Reference in New Issue