stream-chat-react-native-core 5.14.0-beta.4 → 5.14.0-beta.6

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.
@@ -10,7 +10,6 @@ import Animated, {
10
10
  } from 'react-native-reanimated';
11
11
 
12
12
  import type BottomSheet from '@gorhom/bottom-sheet';
13
- import Dayjs from 'dayjs';
14
13
 
15
14
  import { OverlayContext, OverlayProviderProps } from './OverlayContext';
16
15
 
@@ -36,7 +35,6 @@ import { ThemeProvider } from '../themeContext/ThemeContext';
36
35
  import {
37
36
  DEFAULT_USER_LANGUAGE,
38
37
  TranslationProvider,
39
- TranslatorFunctions,
40
38
  } from '../translationContext/TranslationContext';
41
39
 
42
40
  /**
@@ -142,17 +140,13 @@ export const OverlayProvider = <
142
140
 
143
141
  const bottomSheetRef = useRef<BottomSheet>(null);
144
142
 
145
- const [translators, setTranslators] = useState<TranslatorFunctions>({
146
- t: (key: string) => key,
147
- tDateTimeParser: (input?: string | number | Date) => Dayjs(input),
148
- });
149
143
  const [overlay, setOverlay] = useState(value?.overlay || 'none');
150
144
 
151
145
  const overlayOpacity = useSharedValue(0);
152
146
  const { height, width } = Dimensions.get('screen');
153
147
 
154
148
  // Setup translators
155
- const loadingTranslators = useStreami18n(setTranslators, i18nInstance);
149
+ const translators = useStreami18n(i18nInstance);
156
150
 
157
151
  useEffect(() => {
158
152
  const backAction = () => {
@@ -216,8 +210,6 @@ export const OverlayProvider = <
216
210
  translucentStatusBar,
217
211
  };
218
212
 
219
- if (loadingTranslators) return null;
220
-
221
213
  return (
222
214
  <TranslationProvider value={{ ...translators, userLanguage: DEFAULT_USER_LANGUAGE }}>
223
215
  <OverlayContext.Provider value={overlayContext}>
@@ -1,16 +1,19 @@
1
1
  import { useEffect, useState } from 'react';
2
2
 
3
+ import Dayjs from 'dayjs';
4
+
3
5
  import { useIsMountedRef } from './useIsMountedRef';
4
6
 
5
7
  import type { TranslatorFunctions } from '../contexts/translationContext/TranslationContext';
6
8
  import { Streami18n } from '../utils/Streami18n';
7
9
 
8
- export const useStreami18n = (
9
- setTranslators: React.Dispatch<React.SetStateAction<TranslatorFunctions>>,
10
- i18nInstance?: Streami18n,
11
- ) => {
12
- const [loadingTranslators, setLoadingTranslators] = useState(true);
10
+ export const useStreami18n = (i18nInstance?: Streami18n) => {
11
+ const [translators, setTranslators] = useState<TranslatorFunctions>({
12
+ t: (key: string) => key,
13
+ tDateTimeParser: (input?: string | number | Date) => Dayjs(input),
14
+ });
13
15
  const isMounted = useIsMountedRef();
16
+
14
17
  useEffect(() => {
15
18
  let streami18n: Streami18n;
16
19
 
@@ -28,20 +31,21 @@ export const useStreami18n = (
28
31
  streami18n.addOnLanguageChangeListener((t) => {
29
32
  updateTFunction(t);
30
33
  });
34
+
31
35
  const { unsubscribe: unsubscribeOnTFuncOverrideListener } =
32
36
  streami18n.addOnTFunctionOverrideListener((t) => {
33
37
  updateTFunction(t);
34
38
  });
39
+
35
40
  streami18n.getTranslators().then((translator) => {
36
41
  if (translator && isMounted.current) setTranslators(translator);
37
42
  });
38
43
 
39
- setLoadingTranslators(false);
40
44
  return () => {
41
45
  unsubscribeOnTFuncOverrideListener();
42
46
  unsubscribeOnLanguageChangeListener();
43
47
  };
44
48
  }, [i18nInstance]);
45
49
 
46
- return loadingTranslators;
50
+ return translators;
47
51
  };
package/src/version.json CHANGED
@@ -1,3 +1,3 @@
1
1
  {
2
- "version": "5.14.0-beta.4"
2
+ "version": "5.14.0-beta.6"
3
3
  }