Add temporary web event listener for deep link navigation testing in web
browser
This commit is contained in:
parent
b81f7c9ed3
commit
bb1ff4fb11
1 changed files with 13 additions and 0 deletions
|
|
@ -110,11 +110,24 @@
|
||||||
|
|
||||||
// Listen for deep link events
|
// Listen for deep link events
|
||||||
App.addListener("appUrlOpen", (event: URLOpenListenerEvent) => {
|
App.addListener("appUrlOpen", (event: URLOpenListenerEvent) => {
|
||||||
|
console.log(event)
|
||||||
const url = new URL(event.url)
|
const url = new URL(event.url)
|
||||||
const target = `${url.pathname}${url.search}${url.hash}`
|
const target = `${url.pathname}${url.search}${url.hash}`
|
||||||
goto(target, {replaceState: false, noScroll: false})
|
goto(target, {replaceState: false, noScroll: false})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// TEMP: Since the capacitor event won't fire in web, dropping equivalent implementation here for testing navigation
|
||||||
|
//
|
||||||
|
// Event can be manually triggered in web console with: `window.dispatchEvent(new CustomEvent("appUrlOpen", { detail: { url: "foobar:///.well-known/apple-app-site-association" } }) );`
|
||||||
|
window.addEventListener("appUrlOpen", (_event: Event) => {
|
||||||
|
console.log(_event)
|
||||||
|
const event = _event as CustomEvent<{url: string}>
|
||||||
|
const url = new URL(event.detail.url)
|
||||||
|
const target = `${url.pathname}${url.search}${url.hash}`
|
||||||
|
console.log(target)
|
||||||
|
goto(target, {replaceState: false, noScroll: false})
|
||||||
|
})
|
||||||
|
|
||||||
// Nstart login
|
// Nstart login
|
||||||
if (window.location.hash?.startsWith("#nostr-login")) {
|
if (window.location.hash?.startsWith("#nostr-login")) {
|
||||||
const params = new URLSearchParams(window.location.hash.slice(1))
|
const params = new URLSearchParams(window.location.hash.slice(1))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue