forked from coracle/flotilla
9df8cee501
Adopts the rewritten welshman API: the removed @welshman/util helpers (Profile/List/Room/Handler/Encryptable) are now Reader/Builder classes in @welshman/domain, and @welshman/app dropped its global singletons for an App instance + app.use(Plugin) registry. - src/app/welshman.ts is now the app bootstrap + session-state module (one shared App instance, multi-account sessions/login, app-wide reactive views) rather than a compat shim re-exporting the old globals. - Rewrote ~100 callers to use app.use(Plugin) directly (thunks, profiles, relays, rooms, zaps, tags, wot, feeds, sync); thunk helpers are now thunk methods. - Added @welshman/domain dependency. - Resolved residual gaps (storage hydration via plugin.onItem/wrapManager/Plaintext, relay-list mutators, search-relay list, outbox #d filter). Best-effort: no toolchain/linking available, so this is not build- or type-checked. Remaining judgment calls are flagged with TODO(welshman-migration). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BsMjvv7krpZeHK1Njeneru
87 lines
2.6 KiB
Svelte
87 lines
2.6 KiB
Svelte
<script lang="ts">
|
|
import * as nip19 from "nostr-tools/nip19"
|
|
import {onMount} from "svelte"
|
|
import {writable} from "svelte/store"
|
|
import {tryCatch, uniq} from "@welshman/lib"
|
|
import {fromNostrURI} from "@welshman/util"
|
|
import {app} from "@app/welshman"
|
|
import {MessagingRelayLists} from "@welshman/app"
|
|
import {preventDefault} from "@lib/html"
|
|
import Field from "@lib/components/Field.svelte"
|
|
import Button from "@lib/components/Button.svelte"
|
|
import AltArrowLeft from "@assets/icons/alt-arrow-left.svg?dataurl"
|
|
import AltArrowRight from "@assets/icons/alt-arrow-right.svg?dataurl"
|
|
import Icon from "@lib/components/Icon.svelte"
|
|
import Modal from "@lib/components/Modal.svelte"
|
|
import ModalBody from "@lib/components/ModalBody.svelte"
|
|
import ModalHeader from "@lib/components/ModalHeader.svelte"
|
|
import ModalTitle from "@lib/components/ModalTitle.svelte"
|
|
import ModalSubtitle from "@lib/components/ModalSubtitle.svelte"
|
|
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
|
import ProfileMultiSelect from "@app/components/ProfileMultiSelect.svelte"
|
|
import {goToChat} from "@app/routes"
|
|
|
|
const back = () => history.back()
|
|
|
|
const onSubmit = () => goToChat(pubkeys)
|
|
|
|
const addPubkey = (pubkey: string) => {
|
|
pubkeys = uniq([...pubkeys, pubkey])
|
|
term.set("")
|
|
}
|
|
|
|
const term = writable("")
|
|
|
|
let pubkeys: string[] = $state([])
|
|
|
|
$effect(() => {
|
|
pubkeys.forEach(pubkey => app.use(MessagingRelayLists).load(pubkey))
|
|
})
|
|
|
|
onMount(() => {
|
|
return term.subscribe(t => {
|
|
if (t.match(/^[0-9a-f]{64}$/)) {
|
|
addPubkey(t)
|
|
}
|
|
|
|
if (t.match(/^(nostr:)?(npub1|nprofile1)/)) {
|
|
tryCatch(() => {
|
|
const {type, data} = nip19.decode(fromNostrURI(t))
|
|
|
|
if (type === "npub") {
|
|
addPubkey(data)
|
|
}
|
|
|
|
if (type === "nprofile") {
|
|
addPubkey(data.pubkey)
|
|
}
|
|
})
|
|
}
|
|
})
|
|
})
|
|
</script>
|
|
|
|
<Modal tag="form" onsubmit={preventDefault(onSubmit)}>
|
|
<ModalBody>
|
|
<ModalHeader>
|
|
<ModalTitle>Start a Chat</ModalTitle>
|
|
<ModalSubtitle>Create an encrypted chat room for private conversations.</ModalSubtitle>
|
|
</ModalHeader>
|
|
<Field>
|
|
{#snippet input()}
|
|
<ProfileMultiSelect autofocus bind:value={pubkeys} {term} />
|
|
{/snippet}
|
|
</Field>
|
|
</ModalBody>
|
|
<ModalFooter>
|
|
<Button class="btn btn-link" onclick={back}>
|
|
<Icon icon={AltArrowLeft} />
|
|
Go back
|
|
</Button>
|
|
<Button type="submit" class="btn btn-primary" disabled={pubkeys.length === 0}>
|
|
Create Chat
|
|
<Icon icon={AltArrowRight} />
|
|
</Button>
|
|
</ModalFooter>
|
|
</Modal>
|