Skip to content

Scheduling infrastructure for absolutely everyone.

Disables batching for i18n query (#3181)

Omar Lópezdf3e3e8237fb
diff --git a/apps/web/components/I18nLanguageHandler.tsx b/apps/web/components/I18nLanguageHandler.tsx
index 591e7c712af..1a78b6557ee 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 ee8ccc9bbb5..54b899002f0 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 67b062a7ec0..57db0b2baab 100644
--- a/apps/web/pages/_app.tsx
+++ b/apps/web/pages/_app.tsx
@@ -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 }),
diff --git a/apps/web/pages/settings/profile.tsx b/apps/web/pages/settings/profile.tsx
index d20b2ad56fb..a571b0652d2 100644
--- a/apps/web/pages/settings/profile.tsx
+++ b/apps/web/pages/settings/profile.tsx
@@ -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();