@seamly/web-ui 23.0.0-alpha.1 → 23.0.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seamly/web-ui",
3
- "version": "23.0.0-alpha.1",
3
+ "version": "23.0.0-alpha.2",
4
4
  "main": "build/dist/lib/index.js",
5
5
  "types": "build/src/javascripts/index.d.ts",
6
6
  "exports": {
@@ -19,8 +19,8 @@ export const initializeApp = createAsyncThunk<
19
19
  void,
20
20
  ThunkAPI
21
21
  >('initializeApp', async (_, { extra: { api, config }, rejectWithValue }) => {
22
- const contentLocale = config?.context?.contentLocale
23
- const userLocale = config?.context?.userLocale
22
+ let contentLocale = config?.context?.contentLocale
23
+ let userLocale = config?.context?.userLocale
24
24
 
25
25
  const environment =
26
26
  config.api.sendEnvironment !== false
@@ -31,6 +31,9 @@ export const initializeApp = createAsyncThunk<
31
31
  if (api.hasConversation()) {
32
32
  const initialState = await api.getConversationIntitialState()
33
33
 
34
+ contentLocale = initialState.context.contentLocale || contentLocale
35
+ userLocale = initialState.context.userLocale || userLocale
36
+
34
37
  api.sendContext({ ...initialState.context, environment })
35
38
  return { initialState, contentLocale, userLocale, config }
36
39
  } else {
@@ -20,7 +20,7 @@ const TranslationOptions: FC<TranslationOptionsProps> = ({
20
20
  describedById,
21
21
  }) => {
22
22
  const {
23
- context: { contentLocale },
23
+ context: { userLocale, contentLocale },
24
24
  } = useConfig()
25
25
 
26
26
  const { t } = useI18n()
@@ -29,7 +29,7 @@ const TranslationOptions: FC<TranslationOptionsProps> = ({
29
29
  const focusSkiplinkTarget = useSkiplinkTargetFocusing()
30
30
 
31
31
  const handleChange = (locale: Language['locale']) => () => {
32
- if (locale === currentLocale || contentLocale === locale) {
32
+ if (locale === currentLocale || userLocale === locale) {
33
33
  disableTranslations()
34
34
  } else {
35
35
  enableTranslations(locale)
@@ -34,7 +34,9 @@ const createI18nMiddleware: Middleware<{}, RootState, any> = ({
34
34
  }
35
35
 
36
36
  if (initializeApp.fulfilled.match(action)) {
37
- dispatch(setLocale(action.payload.contentLocale))
37
+ if (action.payload.contentLocale) {
38
+ dispatch(setLocale(action.payload.contentLocale))
39
+ }
38
40
  return result
39
41
  }
40
42