forked from coracle/flotilla
Get web push working
This commit is contained in:
@@ -44,6 +44,7 @@
|
||||
} from "@welshman/app"
|
||||
import * as lib from "@welshman/lib"
|
||||
import * as util from "@welshman/util"
|
||||
import * as feeds from "@welshman/feeds"
|
||||
import * as router from "@welshman/router"
|
||||
import * as welshmanSigner from "@welshman/signer"
|
||||
import * as net from "@welshman/net"
|
||||
@@ -84,6 +85,7 @@
|
||||
...welshmanSigner,
|
||||
...router,
|
||||
...util,
|
||||
...feeds,
|
||||
...net,
|
||||
...app,
|
||||
...appState,
|
||||
@@ -92,6 +94,13 @@
|
||||
...notifications,
|
||||
})
|
||||
|
||||
// Listen for navigation messages from service worker
|
||||
navigator.serviceWorker?.addEventListener('message', (event) => {
|
||||
if (event.data && event.data.type === 'NAVIGATE') {
|
||||
goto(event.data.url)
|
||||
}
|
||||
})
|
||||
|
||||
// Nstart login
|
||||
if (window.location.hash?.startsWith("#nostr-login")) {
|
||||
const params = new URLSearchParams(window.location.hash.slice(1))
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
import * as nip19 from "nostr-tools/nip19"
|
||||
import type {TrustedEvent} from "@welshman/util"
|
||||
import {Address, getIdFilters, getTagValue} from "@welshman/util"
|
||||
import {LOCAL_RELAY_URL} from "@welshman/relay"
|
||||
import {load} from "@welshman/net"
|
||||
import {page} from "$app/stores"
|
||||
import {goto} from "$app/navigation"
|
||||
import {scrollToEvent} from "@lib/html"
|
||||
import Spinner from "@lib/components/Spinner.svelte"
|
||||
import {makeRoomPath, makeThreadPath} from "@app/routes"
|
||||
import {goToEvent} from "@app/routes"
|
||||
|
||||
const {bech32} = $page.params
|
||||
|
||||
@@ -22,19 +22,11 @@
|
||||
let found = false
|
||||
|
||||
load({
|
||||
relays: data.relays,
|
||||
relays: [LOCAL_RELAY_URL, ...data.relays],
|
||||
filters: getIdFilters([type === "nevent" ? data.id : Address.fromNaddr(bech32).toString()]),
|
||||
onEvent: (event: TrustedEvent) => {
|
||||
found = true
|
||||
|
||||
if (event.kind === 9) {
|
||||
goto(makeRoomPath(data.relays[0], getTagValue("h", event.tags)!), {replaceState: true})
|
||||
scrollToEvent(event.id)
|
||||
} else if (event.kind === 11) {
|
||||
goto(makeThreadPath(data.relays[0], event.id), {replaceState: true})
|
||||
} else {
|
||||
goto("/", {replaceState: true})
|
||||
}
|
||||
goToEvent(event, {replaceState: true})
|
||||
},
|
||||
onClose: () => {
|
||||
if (!found) {
|
||||
|
||||
Reference in New Issue
Block a user