@swype-org/react-sdk 0.1.262 → 0.1.264
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.cjs +29 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +29 -31
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8681,14 +8681,13 @@ function useMobilePollingEffect(deps) {
|
|
|
8681
8681
|
if (!state.mobileFlow || !mobileSetupFlowRef.current) return;
|
|
8682
8682
|
if (!setupAccountIdRef.current) return;
|
|
8683
8683
|
if (!state.guestPreauthSessionId || !state.isGuestFlow) return;
|
|
8684
|
-
const
|
|
8684
|
+
const guestToken = state.guestSessionToken;
|
|
8685
|
+
const preauthAccountId = state.guestPreauthAccountId;
|
|
8686
|
+
const preauthSessionId = state.guestPreauthSessionId;
|
|
8685
8687
|
let cancelled = false;
|
|
8686
8688
|
let completedGuestPreauth = false;
|
|
8687
8689
|
const POLL_INTERVAL_MS = 3e3;
|
|
8688
|
-
const
|
|
8689
|
-
if (completedGuestPreauth) return;
|
|
8690
|
-
completedGuestPreauth = true;
|
|
8691
|
-
cancelled = true;
|
|
8690
|
+
const finishMobileAndDispatch = async () => {
|
|
8692
8691
|
mobileSetupFlowRef.current = false;
|
|
8693
8692
|
setupAccountIdRef.current = null;
|
|
8694
8693
|
clearMobileFlowState();
|
|
@@ -8696,24 +8695,19 @@ function useMobilePollingEffect(deps) {
|
|
|
8696
8695
|
await reloadAccounts();
|
|
8697
8696
|
} catch {
|
|
8698
8697
|
}
|
|
8699
|
-
|
|
8700
|
-
|
|
8701
|
-
|
|
8702
|
-
|
|
8703
|
-
|
|
8704
|
-
|
|
8705
|
-
}
|
|
8706
|
-
|
|
8707
|
-
|
|
8708
|
-
|
|
8709
|
-
|
|
8710
|
-
|
|
8711
|
-
|
|
8712
|
-
}
|
|
8713
|
-
if (guestLookup == null) {
|
|
8714
|
-
dispatch({ type: "MOBILE_SETUP_COMPLETE" });
|
|
8715
|
-
return;
|
|
8716
|
-
}
|
|
8698
|
+
};
|
|
8699
|
+
const completeGuestPreauthWithoutToken = async () => {
|
|
8700
|
+
if (completedGuestPreauth) return;
|
|
8701
|
+
completedGuestPreauth = true;
|
|
8702
|
+
cancelled = true;
|
|
8703
|
+
await finishMobileAndDispatch();
|
|
8704
|
+
dispatch({ type: "MOBILE_SETUP_COMPLETE" });
|
|
8705
|
+
};
|
|
8706
|
+
const completeGuestPreauthWithAccount = async (guestLookup) => {
|
|
8707
|
+
if (completedGuestPreauth) return;
|
|
8708
|
+
completedGuestPreauth = true;
|
|
8709
|
+
cancelled = true;
|
|
8710
|
+
await finishMobileAndDispatch();
|
|
8717
8711
|
if (guestLookup.accountId !== preauthAccountId) {
|
|
8718
8712
|
dispatch({
|
|
8719
8713
|
type: "GUEST_PREAUTH_DETECTED",
|
|
@@ -8726,24 +8720,28 @@ function useMobilePollingEffect(deps) {
|
|
|
8726
8720
|
}
|
|
8727
8721
|
dispatch({ type: "MOBILE_SETUP_COMPLETE" });
|
|
8728
8722
|
};
|
|
8729
|
-
const
|
|
8723
|
+
const pollGuestAccount = async () => {
|
|
8730
8724
|
try {
|
|
8731
8725
|
if (cancelled) return;
|
|
8732
|
-
|
|
8726
|
+
if (!guestToken) {
|
|
8727
|
+
await completeGuestPreauthWithoutToken();
|
|
8728
|
+
return;
|
|
8729
|
+
}
|
|
8730
|
+
const guestLookup = await fetchGuestAccount(apiBaseUrl, guestToken);
|
|
8733
8731
|
if (cancelled) return;
|
|
8734
|
-
if (
|
|
8735
|
-
await
|
|
8732
|
+
if (guestLookup != null) {
|
|
8733
|
+
await completeGuestPreauthWithAccount(guestLookup);
|
|
8736
8734
|
}
|
|
8737
8735
|
} catch {
|
|
8738
8736
|
}
|
|
8739
8737
|
};
|
|
8740
|
-
|
|
8741
|
-
const intervalId = window.setInterval(
|
|
8738
|
+
pollGuestAccount();
|
|
8739
|
+
const intervalId = window.setInterval(pollGuestAccount, POLL_INTERVAL_MS);
|
|
8742
8740
|
const handleVisibility = () => {
|
|
8743
|
-
if (document.visibilityState === "visible" && !cancelled) void
|
|
8741
|
+
if (document.visibilityState === "visible" && !cancelled) void pollGuestAccount();
|
|
8744
8742
|
};
|
|
8745
8743
|
const handlePageShow = (e) => {
|
|
8746
|
-
if (e.persisted && !cancelled) void
|
|
8744
|
+
if (e.persisted && !cancelled) void pollGuestAccount();
|
|
8747
8745
|
};
|
|
8748
8746
|
document.addEventListener("visibilitychange", handleVisibility);
|
|
8749
8747
|
window.addEventListener("pageshow", handlePageShow);
|