diff --git a/apps/web/components/I18nLanguageHandler.tsx b/apps/web/components/I18nLanguageHandler.tsx index 591e7c712a..1a78b6557e 100644 --- a/apps/web/components/I18nLanguageHandler.tsx +++ b/apps/web/components/I18nLanguageHandler.tsx @@ -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 }, }); } diff --git a/apps/web/lib/app-providers.tsx b/apps/web/lib/app-providers.tsx index ee8ccc9bbb..54b899002f 100644 --- a/apps/web/lib/app-providers.tsx +++ b/apps/web/lib/app-providers.tsx @@ -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", }; diff --git a/apps/web/pages/_app.tsx b/apps/web/pages/_app.tsx index 67b062a7ec..57db0b2baa 100644 --- a/apps/web/pages/_app.tsx +++ b/apps/web/pages/_app.tsx @@ -85,9 +85,7 @@ export default withTRPC({ 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 }), diff --git a/apps/web/pages/settings/profile.tsx b/apps/web/pages/settings/profile.tsx index d20b2ad56f..a571b0652d 100644 --- a/apps/web/pages/settings/profile.tsx +++ b/apps/web/pages/settings/profile.tsx @@ -501,7 +501,11 @@ function SettingsView(props: ComponentProps & { 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();