2024-10-03 22:28:06 +00:00
|
|
|
<script lang="ts">
|
2025-05-29 21:30:22 +00:00
|
|
|
import {onMount} from "svelte"
|
|
|
|
|
import {writable} from "svelte/store"
|
2026-06-18 10:52:04 +00:00
|
|
|
import {uniq} from "@welshman/lib"
|
2026-02-10 00:57:44 +00:00
|
|
|
import {loadMessagingRelayList} from "@welshman/app"
|
2026-06-18 10:52:04 +00:00
|
|
|
import {decodePubkey} from "@lib/util"
|
2025-02-04 03:28:29 +00:00
|
|
|
import {preventDefault} from "@lib/html"
|
2024-10-03 22:28:06 +00:00
|
|
|
import Field from "@lib/components/Field.svelte"
|
|
|
|
|
import Button from "@lib/components/Button.svelte"
|
2025-09-10 22:26:39 +00:00
|
|
|
import AltArrowLeft from "@assets/icons/alt-arrow-left.svg?dataurl"
|
|
|
|
|
import AltArrowRight from "@assets/icons/alt-arrow-right.svg?dataurl"
|
2024-10-03 22:28:06 +00:00
|
|
|
import Icon from "@lib/components/Icon.svelte"
|
2026-01-30 22:14:12 +00:00
|
|
|
import Modal from "@lib/components/Modal.svelte"
|
|
|
|
|
import ModalBody from "@lib/components/ModalBody.svelte"
|
2024-10-10 21:33:50 +00:00
|
|
|
import ModalHeader from "@lib/components/ModalHeader.svelte"
|
2026-02-02 18:09:14 +00:00
|
|
|
import ModalTitle from "@lib/components/ModalTitle.svelte"
|
|
|
|
|
import ModalSubtitle from "@lib/components/ModalSubtitle.svelte"
|
2024-10-10 21:33:50 +00:00
|
|
|
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
2024-10-03 22:28:06 +00:00
|
|
|
import ProfileMultiSelect from "@app/components/ProfileMultiSelect.svelte"
|
2026-06-08 21:14:40 +00:00
|
|
|
import {goToChat} from "@app/routes"
|
2024-10-03 22:28:06 +00:00
|
|
|
|
|
|
|
|
const back = () => history.back()
|
|
|
|
|
|
2026-03-23 21:21:04 +00:00
|
|
|
const onSubmit = () => goToChat(pubkeys)
|
2024-10-03 22:28:06 +00:00
|
|
|
|
2025-05-29 21:30:22 +00:00
|
|
|
const addPubkey = (pubkey: string) => {
|
|
|
|
|
pubkeys = uniq([...pubkeys, pubkey])
|
|
|
|
|
term.set("")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const term = writable("")
|
|
|
|
|
|
2025-02-04 00:37:14 +00:00
|
|
|
let pubkeys: string[] = $state([])
|
2025-05-29 21:30:22 +00:00
|
|
|
|
2026-02-10 00:57:44 +00:00
|
|
|
$effect(() => {
|
|
|
|
|
pubkeys.forEach(pubkey => loadMessagingRelayList(pubkey))
|
|
|
|
|
})
|
|
|
|
|
|
2025-05-29 21:30:22 +00:00
|
|
|
onMount(() => {
|
|
|
|
|
return term.subscribe(t => {
|
2026-06-18 10:52:04 +00:00
|
|
|
const pubkey = decodePubkey(t)
|
2025-05-29 21:30:22 +00:00
|
|
|
|
2026-06-18 10:52:04 +00:00
|
|
|
if (pubkey) {
|
|
|
|
|
addPubkey(pubkey)
|
2025-05-29 21:30:22 +00:00
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
2024-10-03 22:28:06 +00:00
|
|
|
</script>
|
|
|
|
|
|
2026-01-30 22:14:12 +00:00
|
|
|
<Modal tag="form" onsubmit={preventDefault(onSubmit)}>
|
|
|
|
|
<ModalBody>
|
|
|
|
|
<ModalHeader>
|
2026-02-02 18:09:14 +00:00
|
|
|
<ModalTitle>Start a Chat</ModalTitle>
|
|
|
|
|
<ModalSubtitle>Create an encrypted chat room for private conversations.</ModalSubtitle>
|
2026-01-30 22:14:12 +00:00
|
|
|
</ModalHeader>
|
|
|
|
|
<Field>
|
|
|
|
|
{#snippet input()}
|
|
|
|
|
<ProfileMultiSelect autofocus bind:value={pubkeys} {term} />
|
|
|
|
|
{/snippet}
|
|
|
|
|
</Field>
|
|
|
|
|
</ModalBody>
|
2024-10-10 21:33:50 +00:00
|
|
|
<ModalFooter>
|
2026-06-24 20:56:53 +00:00
|
|
|
<Button class="button button-link" onclick={back}>
|
2025-09-10 22:26:39 +00:00
|
|
|
<Icon icon={AltArrowLeft} />
|
2024-10-03 22:28:06 +00:00
|
|
|
Go back
|
|
|
|
|
</Button>
|
2026-06-24 20:56:53 +00:00
|
|
|
<Button type="submit" class="button button-primary" disabled={pubkeys.length === 0}>
|
2024-10-03 22:28:06 +00:00
|
|
|
Create Chat
|
2025-09-10 22:26:39 +00:00
|
|
|
<Icon icon={AltArrowRight} />
|
2024-10-03 22:28:06 +00:00
|
|
|
</Button>
|
2024-10-10 21:33:50 +00:00
|
|
|
</ModalFooter>
|
2026-01-30 22:14:12 +00:00
|
|
|
</Modal>
|