@trustchex/react-native-sdk 1.248.0 → 1.249.0

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.
@@ -35,6 +35,7 @@ const Trustchex = ({
35
35
  const [baseUrl, setBaseUrl] = useState(null);
36
36
  const [sessionId, setSessionId] = useState(null);
37
37
  const [locale, setLocale] = useState(propLocale || i18n.language);
38
+ const [isInitialized, setIsInitialized] = useState(false);
38
39
  const branding = useMemo(() => ({
39
40
  ...DEFAULT_BRANDING,
40
41
  ...propBranding
@@ -69,22 +70,29 @@ const Trustchex = ({
69
70
  initializeTTS();
70
71
  }, []);
71
72
  useEffect(() => {
72
- if (propBaseUrl) {
73
- setBaseUrl(propBaseUrl);
74
- }
75
- }, [propBaseUrl]);
76
- useEffect(() => {
77
- if (propSessionId) {
78
- setSessionId(propSessionId);
79
- }
80
- }, [propSessionId]);
73
+ const timer = setTimeout(() => {
74
+ let shouldUpdate = false;
75
+ if (propBaseUrl && propBaseUrl !== baseUrl) {
76
+ shouldUpdate = true;
77
+ }
78
+ if (propSessionId !== undefined && propSessionId !== sessionId) {
79
+ shouldUpdate = true;
80
+ }
81
+ if (shouldUpdate && propBaseUrl && propSessionId !== undefined) {
82
+ setBaseUrl(propBaseUrl);
83
+ setSessionId(propSessionId);
84
+ }
85
+ setIsInitialized(true);
86
+ }, 100);
87
+ return () => clearTimeout(timer);
88
+ }, [propBaseUrl, propSessionId, baseUrl, sessionId]);
81
89
  useEffect(() => {
82
90
  if (propLocale) {
83
91
  setLocale(propLocale);
84
92
  i18n.changeLanguage(propLocale);
85
93
  }
86
94
  }, [propLocale]);
87
- if (!baseUrl) {
95
+ if (!baseUrl || !isInitialized) {
88
96
  return /*#__PURE__*/_jsx(View, {
89
97
  style: styles.loadingContainer,
90
98
  children: /*#__PURE__*/_jsx(ActivityIndicator, {
@@ -1 +1 @@
1
- {"version":3,"file":"Trustchex.d.ts","sourceRoot":"","sources":["../../../src/Trustchex.tsx"],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S,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CA2IvC,CAAC;AAWF,eAAe,SAAS,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trustchex/react-native-sdk",
3
- "version": "1.248.0",
3
+ "version": "1.249.0",
4
4
  "description": "Trustchex mobile app react native SDK for android or ios devices",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
package/src/Trustchex.tsx CHANGED
@@ -52,6 +52,7 @@ const Trustchex: React.FC<TrustchexProps> = ({
52
52
  const [baseUrl, setBaseUrl] = useState<string | null>(null);
53
53
  const [sessionId, setSessionId] = useState<string | null>(null);
54
54
  const [locale, setLocale] = useState(propLocale || i18n.language);
55
+ const [isInitialized, setIsInitialized] = useState(false);
55
56
 
56
57
  const branding = useMemo(
57
58
  () => ({
@@ -100,16 +101,27 @@ const Trustchex: React.FC<TrustchexProps> = ({
100
101
  }, []);
101
102
 
102
103
  useEffect(() => {
103
- if (propBaseUrl) {
104
- setBaseUrl(propBaseUrl);
105
- }
106
- }, [propBaseUrl]);
104
+ const timer = setTimeout(() => {
105
+ let shouldUpdate = false;
107
106
 
108
- useEffect(() => {
109
- if (propSessionId) {
110
- setSessionId(propSessionId);
111
- }
112
- }, [propSessionId]);
107
+ if (propBaseUrl && propBaseUrl !== baseUrl) {
108
+ shouldUpdate = true;
109
+ }
110
+
111
+ if (propSessionId !== undefined && propSessionId !== sessionId) {
112
+ shouldUpdate = true;
113
+ }
114
+
115
+ if (shouldUpdate && propBaseUrl && propSessionId !== undefined) {
116
+ setBaseUrl(propBaseUrl);
117
+ setSessionId(propSessionId);
118
+ }
119
+
120
+ setIsInitialized(true);
121
+ }, 100);
122
+
123
+ return () => clearTimeout(timer);
124
+ }, [propBaseUrl, propSessionId, baseUrl, sessionId]);
113
125
 
114
126
  useEffect(() => {
115
127
  if (propLocale) {
@@ -118,7 +130,7 @@ const Trustchex: React.FC<TrustchexProps> = ({
118
130
  }
119
131
  }, [propLocale]);
120
132
 
121
- if (!baseUrl) {
133
+ if (!baseUrl || !isInitialized) {
122
134
  return (
123
135
  <View style={styles.loadingContainer}>
124
136
  <ActivityIndicator size="large" color={branding.primaryColor} />