@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.js CHANGED
@@ -4510,6 +4510,7 @@ function SwypePaymentInner({
4510
4510
  const pollingTransferIdRef = useRef(null);
4511
4511
  const mobileSigningTransferIdRef = useRef(null);
4512
4512
  const mobileSetupFlowRef = useRef(false);
4513
+ const handlingMobileReturnRef = useRef(false);
4513
4514
  const processingStartedAtRef = useRef(null);
4514
4515
  const [selectSourceChainName, setSelectSourceChainName] = useState("");
4515
4516
  const [selectSourceTokenSymbol, setSelectSourceTokenSymbol] = useState("");
@@ -4552,6 +4553,8 @@ function SwypePaymentInner({
4552
4553
  polling.startPolling(persisted.transferId);
4553
4554
  }, [polling]);
4554
4555
  const handleAuthorizedMobileReturn = useCallback(async (authorizedTransfer, isSetup) => {
4556
+ if (handlingMobileReturnRef.current) return;
4557
+ handlingMobileReturnRef.current = true;
4555
4558
  polling.stopPolling();
4556
4559
  if (isSetup) {
4557
4560
  mobileSetupFlowRef.current = false;
@@ -4565,6 +4568,7 @@ function SwypePaymentInner({
4565
4568
  setMobileFlow(false);
4566
4569
  setStep("deposit");
4567
4570
  } catch (err) {
4571
+ handlingMobileReturnRef.current = false;
4568
4572
  setError(
4569
4573
  err instanceof Error ? err.message : "Wallet authorized, but we could not refresh your account yet."
4570
4574
  );
@@ -4582,6 +4586,7 @@ function SwypePaymentInner({
4582
4586
  }, [polling.stopPolling, reloadAccounts, resetDataLoadingState]);
4583
4587
  const handleRetryMobileStatus = useCallback(() => {
4584
4588
  setError(null);
4589
+ handlingMobileReturnRef.current = false;
4585
4590
  const currentTransfer = polling.transfer ?? transfer;
4586
4591
  if (currentTransfer?.status === "AUTHORIZED") {
4587
4592
  void handleAuthorizedMobileReturn(currentTransfer, mobileSetupFlowRef.current);
@@ -4927,18 +4932,23 @@ function SwypePaymentInner({
4927
4932
  return () => window.clearTimeout(timeoutId);
4928
4933
  }, [step, polling.transfer, transfer, polling.stopPolling, onError]);
4929
4934
  useEffect(() => {
4930
- if (!mobileFlow) return;
4935
+ if (!mobileFlow) {
4936
+ handlingMobileReturnRef.current = false;
4937
+ return;
4938
+ }
4939
+ if (handlingMobileReturnRef.current) return;
4931
4940
  const polledTransfer = polling.transfer;
4932
4941
  if (!polledTransfer || polledTransfer.status !== "AUTHORIZED") return;
4933
4942
  void handleAuthorizedMobileReturn(polledTransfer, mobileSetupFlowRef.current);
4934
4943
  }, [mobileFlow, polling.transfer, handleAuthorizedMobileReturn]);
4935
4944
  useEffect(() => {
4936
4945
  if (!mobileFlow) return;
4946
+ if (handlingMobileReturnRef.current) return;
4937
4947
  const transferIdToResume = pollingTransferIdRef.current ?? transfer?.id;
4938
4948
  if (!transferIdToResume) return;
4939
4949
  if (!polling.isPolling) polling.startPolling(transferIdToResume);
4940
4950
  const handleVisibility = () => {
4941
- if (document.visibilityState === "visible") {
4951
+ if (document.visibilityState === "visible" && !handlingMobileReturnRef.current) {
4942
4952
  polling.startPolling(transferIdToResume);
4943
4953
  }
4944
4954
  };
@@ -5222,6 +5232,7 @@ function SwypePaymentInner({
5222
5232
  userAgent: typeof navigator === "undefined" ? void 0 : navigator.userAgent
5223
5233
  });
5224
5234
  if (isMobile) {
5235
+ handlingMobileReturnRef.current = false;
5225
5236
  mobileSetupFlowRef.current = true;
5226
5237
  const amount2 = depositAmount ?? 5;
5227
5238
  handlePay(amount2, { sourceType: "providerId", sourceId: providerId });