From c44e75a11f57842e1511ac768a858f8ed3d9c9f0 Mon Sep 17 00:00:00 2001 From: Aleksandar Cakalic Date: Fri, 31 Jan 2025 16:52:48 +0100 Subject: [PATCH] refactor: trigger app deep link if user is on mobile devices --- .../argent/argentMobile/modal/argentModal.ts | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/connectors/argent/argentMobile/modal/argentModal.ts b/src/connectors/argent/argentMobile/modal/argentModal.ts index 14bfc5d..bf53c76 100644 --- a/src/connectors/argent/argentMobile/modal/argentModal.ts +++ b/src/connectors/argent/argentMobile/modal/argentModal.ts @@ -1,8 +1,8 @@ -import { getDevice } from "./getDevice" +import { getDevice } from "../../../../helpers/getDevice" import Modal from "../../../../modal/Modal.svelte" import { Layout, type ModalWallet } from "../../../../types/modal" import { getModalTarget } from "../../../../helpers/modal" -import { StarknetkitConnector } from "../../../connector" +import type { StarknetkitConnector } from "../../../connector" const device = getDevice() @@ -56,8 +56,8 @@ class ArgentModal { this.showModal( { desktop: `${this.bridgeUrl}?wc=${wcParam}&href=${href}&device=desktop&onlyQR=true`, - ios: `${this.mobileUrl}app/wc?uri=${wcParam}&href=${href}&device=mobile`, - android: `${this.mobileUrl}app/wc?uri=${wcParam}&href=${href}&device=mobile`, + ios: `${this.mobileUrl}app/wc?uri=${wcParam}&href=${href}&device=mobile&onlyQR=true`, + android: `${this.mobileUrl}app/wc?uri=${wcParam}&href=${href}&device=mobile&onlyQR=true`, }, modalWallet, ) @@ -69,8 +69,8 @@ class ArgentModal { this.getQR({ desktop: `${this.bridgeUrl}?wc=${wcParam}&href=${href}&device=desktop&onlyQR=true`, - ios: `${this.mobileUrl}app/wc?uri=${wcParam}&href=${href}&device=mobile`, - android: `${this.mobileUrl}app/wc?uri=${wcParam}&href=${href}&device=mobile`, + ios: `${this.mobileUrl}app/wc?uri=${wcParam}&href=${href}&device=mobile&onlyQR=true`, + android: `${this.mobileUrl}app/wc?uri=${wcParam}&href=${href}&device=mobile&onlyQR=true`, }) } @@ -78,6 +78,17 @@ class ArgentModal { const overlay = document.createElement("div") const shadow = document.querySelector("#starknetkit-modal-container") + if (["android", "ios"].includes(device)) { + const toMobileApp = document.createElement("button") + toMobileApp.style.display = "none" + toMobileApp.addEventListener("click", () => { + window.location.href = urls[device] + }) + toMobileApp.click() + + return + } + if (shadow?.shadowRoot) { const slot = shadow.shadowRoot.querySelector(".qr-code-slot")