@jokkoo/sdk-react 0.1.0 → 0.1.1
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/dist/index.js +20 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -518,7 +518,15 @@ function JokkooProvider({
|
|
|
518
518
|
}
|
|
519
519
|
const queryClient = externalQueryClient ?? internalQueryClientRef.current;
|
|
520
520
|
const translations = (0, import_react2.useMemo)(() => (0, import_sdk_web3.getTranslations)(locale), [locale]);
|
|
521
|
-
const
|
|
521
|
+
const configKey = [
|
|
522
|
+
clientToken,
|
|
523
|
+
baseUrl ?? "",
|
|
524
|
+
locale ?? "",
|
|
525
|
+
String(debug ?? false),
|
|
526
|
+
String(tokenRefreshBufferSeconds ?? "")
|
|
527
|
+
].join("\0");
|
|
528
|
+
const clientsRef = (0, import_react2.useRef)(null);
|
|
529
|
+
if (clientsRef.current?.configKey !== configKey || !import_sdk_web3.Jokkoo.isInitialized()) {
|
|
522
530
|
import_sdk_web3.Jokkoo.init({
|
|
523
531
|
clientToken,
|
|
524
532
|
baseUrl,
|
|
@@ -527,10 +535,15 @@ function JokkooProvider({
|
|
|
527
535
|
tokenRefreshBufferSeconds,
|
|
528
536
|
userTokenProvider: () => tokenProviderRef.current()
|
|
529
537
|
});
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
538
|
+
const realtimeClient2 = import_sdk_web3.Jokkoo.getRealtimeClient();
|
|
539
|
+
void realtimeClient2.connect();
|
|
540
|
+
clientsRef.current = {
|
|
541
|
+
configKey,
|
|
542
|
+
apiClient: new import_sdk_web3.JokkooApiClient(import_sdk_web3.Jokkoo.getConfig(), import_sdk_web3.Jokkoo.getTokenManager()),
|
|
543
|
+
realtimeClient: realtimeClient2
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
const { apiClient, realtimeClient } = clientsRef.current;
|
|
534
547
|
const { unreadCount, markConversationRead, isConversationUnread } = useGlobalRealtimeListener({
|
|
535
548
|
apiClient,
|
|
536
549
|
realtimeClient,
|
|
@@ -540,9 +553,10 @@ function JokkooProvider({
|
|
|
540
553
|
});
|
|
541
554
|
(0, import_react2.useEffect)(() => {
|
|
542
555
|
return () => {
|
|
556
|
+
clientsRef.current = null;
|
|
543
557
|
import_sdk_web3.Jokkoo.destroy();
|
|
544
558
|
};
|
|
545
|
-
}, []);
|
|
559
|
+
}, [configKey]);
|
|
546
560
|
const resetNavigation = (0, import_react2.useCallback)(() => {
|
|
547
561
|
setCurrentScreen(initialScreen);
|
|
548
562
|
setIsExpanded(false);
|