@swype-org/react-sdk 0.1.73 → 0.1.75

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 CHANGED
@@ -4513,6 +4513,7 @@ function SwypePaymentInner({
4513
4513
  const pollingTransferIdRef = react.useRef(null);
4514
4514
  const mobileSigningTransferIdRef = react.useRef(null);
4515
4515
  const mobileSetupFlowRef = react.useRef(false);
4516
+ const handlingMobileReturnRef = react.useRef(false);
4516
4517
  const processingStartedAtRef = react.useRef(null);
4517
4518
  const [selectSourceChainName, setSelectSourceChainName] = react.useState("");
4518
4519
  const [selectSourceTokenSymbol, setSelectSourceTokenSymbol] = react.useState("");
@@ -4555,6 +4556,8 @@ function SwypePaymentInner({
4555
4556
  polling.startPolling(persisted.transferId);
4556
4557
  }, [polling]);
4557
4558
  const handleAuthorizedMobileReturn = react.useCallback(async (authorizedTransfer, isSetup) => {
4559
+ if (handlingMobileReturnRef.current) return;
4560
+ handlingMobileReturnRef.current = true;
4558
4561
  polling.stopPolling();
4559
4562
  if (isSetup) {
4560
4563
  mobileSetupFlowRef.current = false;
@@ -4568,6 +4571,7 @@ function SwypePaymentInner({
4568
4571
  setMobileFlow(false);
4569
4572
  setStep("deposit");
4570
4573
  } catch (err) {
4574
+ handlingMobileReturnRef.current = false;
4571
4575
  setError(
4572
4576
  err instanceof Error ? err.message : "Wallet authorized, but we could not refresh your account yet."
4573
4577
  );
@@ -4585,6 +4589,7 @@ function SwypePaymentInner({
4585
4589
  }, [polling.stopPolling, reloadAccounts, resetDataLoadingState]);
4586
4590
  const handleRetryMobileStatus = react.useCallback(() => {
4587
4591
  setError(null);
4592
+ handlingMobileReturnRef.current = false;
4588
4593
  const currentTransfer = polling.transfer ?? transfer;
4589
4594
  if (currentTransfer?.status === "AUTHORIZED") {
4590
4595
  void handleAuthorizedMobileReturn(currentTransfer, mobileSetupFlowRef.current);
@@ -4930,18 +4935,23 @@ function SwypePaymentInner({
4930
4935
  return () => window.clearTimeout(timeoutId);
4931
4936
  }, [step, polling.transfer, transfer, polling.stopPolling, onError]);
4932
4937
  react.useEffect(() => {
4933
- if (!mobileFlow) return;
4938
+ if (!mobileFlow) {
4939
+ handlingMobileReturnRef.current = false;
4940
+ return;
4941
+ }
4942
+ if (handlingMobileReturnRef.current) return;
4934
4943
  const polledTransfer = polling.transfer;
4935
4944
  if (!polledTransfer || polledTransfer.status !== "AUTHORIZED") return;
4936
4945
  void handleAuthorizedMobileReturn(polledTransfer, mobileSetupFlowRef.current);
4937
4946
  }, [mobileFlow, polling.transfer, handleAuthorizedMobileReturn]);
4938
4947
  react.useEffect(() => {
4939
4948
  if (!mobileFlow) return;
4949
+ if (handlingMobileReturnRef.current) return;
4940
4950
  const transferIdToResume = pollingTransferIdRef.current ?? transfer?.id;
4941
4951
  if (!transferIdToResume) return;
4942
4952
  if (!polling.isPolling) polling.startPolling(transferIdToResume);
4943
4953
  const handleVisibility = () => {
4944
- if (document.visibilityState === "visible") {
4954
+ if (document.visibilityState === "visible" && !handlingMobileReturnRef.current) {
4945
4955
  polling.startPolling(transferIdToResume);
4946
4956
  }
4947
4957
  };
@@ -5225,6 +5235,7 @@ function SwypePaymentInner({
5225
5235
  userAgent: typeof navigator === "undefined" ? void 0 : navigator.userAgent
5226
5236
  });
5227
5237
  if (isMobile) {
5238
+ handlingMobileReturnRef.current = false;
5228
5239
  mobileSetupFlowRef.current = true;
5229
5240
  const amount2 = depositAmount ?? 5;
5230
5241
  handlePay(amount2, { sourceType: "providerId", sourceId: providerId });