Rallly is an open-source scheduling and collaboration tool designed to make organizing events and meetings easier.
TypeScript i18nextnext-authnextjspostgresqlprismareact-emailt3-stacktailwindcsstrpcturborepotypescriptzod
🔥 Remove locale sync (#2666)
Luke Vella4f4b29050b42
diff --git a/apps/web/src/app/[locale]/(optional-space)/layout.tsx b/apps/web/src/app/[locale]/(optional-space)/layout.tsxindex 09943a019..26b28e5fc 100644--- a/apps/web/src/app/[locale]/(optional-space)/layout.tsx+++ b/apps/web/src/app/[locale]/(optional-space)/layout.tsx@@ -5,7 +5,6 @@ import { isQuickCreateEnabled } from "@/features/quick-create/constants";import { getLocale } from "@/i18n/server/get-locale";import { DeviceDateTimeProvider } from "@/lib/datetime/device";import { getDeviceDateTimeConfig } from "@/lib/datetime/server";-import { LocaleSync } from "@/lib/locale/client";import {createPrivateSSRHelper,createPublicSSRHelper,@@ -30,7 +29,6 @@ export default async function Layout({return (<HydrationBoundary state={dehydrate(helpers.queryClient)}><SessionRefresher />- <LocaleSync userLocale={user?.locale ?? undefined} /><DeviceDateTimeProviderlocale={locale}timeZone={user?.timeZone ?? deviceDateTimeConfig.timeZone ?? undefined}diff --git a/apps/web/src/app/[locale]/(space)/layout.tsx b/apps/web/src/app/[locale]/(space)/layout.tsxindex f73564d5f..63ea96ab7 100644--- a/apps/web/src/app/[locale]/(space)/layout.tsx+++ b/apps/web/src/app/[locale]/(space)/layout.tsx@@ -6,7 +6,6 @@ import { SpaceProvider } from "@/features/space/client";import { TimeZoneMismatchDialog } from "@/features/user/components/timezone-mismatch-dialog";import { getLocale } from "@/i18n/server/get-locale";import { DateTimeProvider } from "@/lib/datetime/client";-import { LocaleSync } from "@/lib/locale/client";import { getPathname } from "@/lib/pathname";import { buildSafeRedirectUrl } from "@/lib/utils/redirect";import { createPrivateSSRHelper } from "@/trpc/server/create-ssr-helper";@@ -34,7 +33,6 @@ export default async function Layout({return (<HydrationBoundary state={dehydrate(helpers.queryClient)}><SessionRefresher />- <LocaleSync userLocale={user?.locale} /><TimeZoneMismatchDialog homeTimeZone={user?.timeZone} /><DateTimeProviderlocale={locale}diff --git a/apps/web/src/app/[locale]/invite/[urlId]/page.tsx b/apps/web/src/app/[locale]/invite/[urlId]/page.tsxindex 12baa7bdb..4759793c7 100644--- a/apps/web/src/app/[locale]/invite/[urlId]/page.tsx+++ b/apps/web/src/app/[locale]/invite/[urlId]/page.tsx@@ -9,7 +9,6 @@ import { PermissionProvider } from "@/features/poll/client";import { getLocale } from "@/i18n/server/get-locale";import { DeviceDateTimeProvider } from "@/lib/datetime/device";import { getDeviceDateTimeConfig } from "@/lib/datetime/server";-import { LocaleSync } from "@/lib/locale/client";import { decryptToken } from "@/lib/session";import { createPublicSSRHelper } from "@/trpc/server/create-ssr-helper";import { InvitePageLoader } from "./invite-page-loader";@@ -69,7 +68,6 @@ export default async function Page(props: {return (<HydrationBoundary state={dehydrate(trpc.queryClient)}><SessionRefresher />- <LocaleSync userLocale={user?.locale ?? undefined} /><DeviceDateTimeProviderlocale={locale}timeZone={deviceDateTimeConfig.timeZone}diff --git a/apps/web/src/lib/locale/client.tsx b/apps/web/src/lib/locale/client.tsxindex 21979d0db..32326b63f 100644--- a/apps/web/src/lib/locale/client.tsx+++ b/apps/web/src/lib/locale/client.tsx@@ -1,45 +1,5 @@"use client";-import { toast } from "@rallly/ui/sonner";-import Cookies from "js-cookie";-import { useParams, useRouter } from "next/navigation";-import React from "react";-import { useTranslation } from "@/i18n/client";-import {- LOCALE_COOKIE_NAME,- LOCALE_COOKIE_OPTIONS,-} from "@/lib/locale/constants";--export function LocaleSync({ userLocale }: { userLocale?: string }) {- const { locale } = useLocale();- const router = useRouter();- const { t } = useTranslation();-- React.useEffect(() => {- // update the cookie with the user locale if it's different from the current locale- if (userLocale && locale !== userLocale) {- setLocaleCookie(userLocale);- toast.info(- t("localeSyncToast", {- defaultValue: "Your language preferences changed",- }),- {- action: {- label: "Refresh",- onClick: () => {- router.refresh();- },- },- },- );- }- }, [locale, userLocale, router, t]);-- return null;-}--function setLocaleCookie(locale: string) {- Cookies.set(LOCALE_COOKIE_NAME, locale, LOCALE_COOKIE_OPTIONS);-}+import { useParams } from "next/navigation";export function useLocale() {const { locale } = useParams();