From 7a981923f63eb2d23d3e24df07b6c73d559033f9 Mon Sep 17 00:00:00 2001 From: Zach Pomerantz Date: Wed, 20 Sep 2023 09:32:50 -0700 Subject: [PATCH] fix: do not re-init active locale (#7329) --- src/lib/i18n.tsx | 1 + src/state/user/reducer.ts | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lib/i18n.tsx b/src/lib/i18n.tsx index bc302c791b..b373c6fbe2 100644 --- a/src/lib/i18n.tsx +++ b/src/lib/i18n.tsx @@ -10,6 +10,7 @@ i18n.load(DEFAULT_LOCALE, DEFAULT_MESSAGES) i18n.activate(DEFAULT_LOCALE) export async function dynamicActivate(locale: SupportedLocale) { + if (i18n.locale === locale) return try { const catalog = await import(`locales/${locale}.js`) // Bundlers will either export it as default or as a named export named default. diff --git a/src/state/user/reducer.ts b/src/state/user/reducer.ts index fa0529e471..7bf0507ce6 100644 --- a/src/state/user/reducer.ts +++ b/src/state/user/reducer.ts @@ -78,8 +78,10 @@ const userSlice = createSlice({ state.selectedWallet = wallet }, updateUserLocale(state, action) { - state.userLocale = action.payload.userLocale - state.timestamp = currentTimestamp() + if (action.payload.userLocale !== state.userLocale) { + state.userLocale = action.payload.userLocale + state.timestamp = currentTimestamp() + } }, updateUserSlippageTolerance(state, action) { state.userSlippageTolerance = action.payload.userSlippageTolerance