forked from coracle/flotilla
Add ChannelMessageMenuMobile
This commit is contained in:
@@ -2,11 +2,11 @@
|
||||
import {nip19} from "nostr-tools"
|
||||
import {nthEq} from "@welshman/lib"
|
||||
import {Address} from "@welshman/util"
|
||||
import {trackerStore} from "@welshman/app"
|
||||
import type {TrustedEvent} from "@welshman/util"
|
||||
import Link from "@lib/components/Link.svelte"
|
||||
import Spinner from "@lib/components/Spinner.svelte"
|
||||
import NoteCard from "@app/components/NoteCard.svelte"
|
||||
import {deriveEvent, entityLink, userMembership, getMembershipUrls, COMMENT} from "@app/state"
|
||||
import {deriveEvent, entityLink, MESSAGE, THREAD} from "@app/state"
|
||||
import {makeThreadPath} from "@app/routes"
|
||||
|
||||
export let value
|
||||
@@ -18,13 +18,26 @@
|
||||
const event = deriveEvent(idOrAddress, relays)
|
||||
const entity = id ? nip19.neventEncode({id, relays}) : addr.toNaddr()
|
||||
|
||||
const getLocalHref = (e: TrustedEvent) => {
|
||||
const url = e.tags.find(nthEq(0, "~"))?.[2]
|
||||
console.log(e, url)
|
||||
|
||||
if (!url) return
|
||||
if ([MESSAGE, THREAD].includes(e.kind)) return makeThreadPath(url, e.id)
|
||||
|
||||
const kind = e.tags.find(nthEq(0, "K"))?.[1]
|
||||
const id = e.tags.find(nthEq(0, "E"))?.[1]
|
||||
|
||||
if (!id || !kind) return
|
||||
if ([MESSAGE, THREAD].includes(parseInt(kind))) return makeThreadPath(url, id)
|
||||
}
|
||||
|
||||
// If we found this event on a relay that the user is a member of, redirect internally
|
||||
$: url = getMembershipUrls($userMembership).find(url => $trackerStore.hasRelay($event?.id, url))
|
||||
$: root = $event?.kind === COMMENT ? $event.tags.find(nthEq(0, "E"))?.[1] : $event?.id
|
||||
$: href = url && root ? makeThreadPath(url, root) : entityLink(entity)
|
||||
$: localHref = getLocalHref($event)
|
||||
$: href = localHref || entityLink(entity)
|
||||
</script>
|
||||
|
||||
<Link external={!url} {href} class="my-2 block max-w-full text-left">
|
||||
<Link external={!localHref} {href} class="my-2 block max-w-full text-left">
|
||||
{#if $event}
|
||||
<NoteCard event={$event} class="bg-alt rounded-box p-4">
|
||||
<slot name="note-content" event={$event} {depth} />
|
||||
|
||||
Reference in New Issue
Block a user