Skip to content

Commit

Permalink
refactor: trigger app deep link if user is on mobile devices
Browse files Browse the repository at this point in the history
  • Loading branch information
Cussone committed Jan 31, 2025
1 parent fecae28 commit c44e75a
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/connectors/argent/argentMobile/modal/argentModal.ts
Original file line number Diff line number Diff line change
@@ -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()

Expand Down Expand Up @@ -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,
)
Expand All @@ -69,15 +69,26 @@ 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`,
})
}

private getQR(urls: Urls) {
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")

Expand Down

0 comments on commit c44e75a

Please sign in to comment.