Skip to content

Commit

Permalink
fix: open webwallet with click
Browse files Browse the repository at this point in the history
  • Loading branch information
bluecco committed Nov 7, 2023
1 parent 759596e commit 1b55b6e
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/connectors/webwallet/helpers/trpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,25 @@ export const trpcProxyClient = ({
false: popupLink({
listenWindow: window,
createPopup: () => {
// parent is the window that opened this window; if not detected then it falls back to the current screen
let popup: Window | null = null
const webwalletBtn = document.createElement("button")
webwalletBtn.style.display = "none"
webwalletBtn.addEventListener("click", () => {
popup = window.open(
`${popupOrigin}${popupLocation}`,
"popup",
popupParams,
)
})
webwalletBtn.click()

const popup = window.open(
`${popupOrigin}${popupLocation}`,
"popup",
popupParams,
)
// make sure popup is defined
;(async () => {
console.log(popup)
while (!popup) {
await new Promise((resolve) => setTimeout(resolve, 100))
}
})()

if (!popup) {
throw new Error("Could not open popup")
Expand Down

0 comments on commit 1b55b6e

Please sign in to comment.