diff --git a/src/app/views/ChannelsDetail.svelte b/src/app/views/ChannelsDetail.svelte index a1fafad7..6710eec4 100644 --- a/src/app/views/ChannelsDetail.svelte +++ b/src/app/views/ChannelsDetail.svelte @@ -1,23 +1,24 @@ + + -
-
- - -
-
-
- {#each pubkeys as pubkey, i (pubkey)} - {#if i > 0}•{/if} - showPerson(pubkey)}> - {displayProfileByPubkey(pubkey)} - - {/each} +
+
+
+ + +
+
+
+ {#each pubkeys as pubkey, i (pubkey)} + {#if i > 0}•{/if} + showPerson(pubkey)}> + {displayProfileByPubkey(pubkey)} + + {/each} +
+ {#if pubkeys.length === 1} + + {/if}
- {#if pubkeys.length === 1} - - {/if}
+ {#if $pubkeysWithoutInbox.length > 0} +
+
+ {$pubkeysWithoutInbox.length} inbox is not configured +
+
+ + + {$pubkeysWithoutInbox.length} + +
+
+ {/if}
diff --git a/src/engine/commands.ts b/src/engine/commands.ts index 5dbbd3ce..3c12e0c9 100644 --- a/src/engine/commands.ts +++ b/src/engine/commands.ts @@ -409,25 +409,6 @@ export const markAsSeen = async (kind: number, eventsByKey: Record { - const $pubkey = pubkey.get() - const recipients = without([$pubkey], channelId.split(",")) - - if (recipients.length > 1) { - throw new Error("Attempted to send legacy message to more than 1 recipient") - } - - const recipient = recipients[0] || $pubkey - - return createAndPublish({ - kind: 4, - tags: [tagPubkey(recipient), ...getClientTags()], - content: await signer.get().nip04.encrypt(recipient, content), - relays: ctx.app.router.PubkeyInbox(recipient).getUrls(), - forcePlatform: false, - }) -} - export const sendMessage = async (channelId: string, content: string) => { const recipients = channelId.split(",") const template = { diff --git a/src/partials/Channel.svelte b/src/partials/Channel.svelte index 59ebe203..1011e877 100644 --- a/src/partials/Channel.svelte +++ b/src/partials/Channel.svelte @@ -3,7 +3,7 @@ import {onMount} from "svelte" import {pluralize} from "hurdak" import {derived} from "svelte/store" - import {sleep, remove} from "@welshman/lib" + import {sleep} from "@welshman/lib" import type {TrustedEvent} from "@welshman/util" import {Nip46Signer} from "@welshman/signer" import { @@ -18,7 +18,6 @@ import Spinner from "src/partials/Spinner.svelte" import Anchor from "src/partials/Anchor.svelte" import Popover from "src/partials/Popover.svelte" - import Toggle from "src/partials/Toggle.svelte" import FlexColumn from "src/partials/FlexColumn.svelte" import Modal from "src/partials/Modal.svelte" import Subheading from "src/partials/Subheading.svelte" @@ -30,14 +29,13 @@ import Compose from "src/app/shared/Compose.svelte" export let pubkeys - export let sendMessage + export let sendMessage: (content: string) => Promise export let initialMessage = "" export let messages: TrustedEvent[] let editor: Editor const loading = sleep(5_000) - const toggleScale = 0.7 const startScroller = () => { scroller?.stop() @@ -65,14 +63,10 @@ let showNewMessages = false let groupedMessages = [] - const isGroupMessage = pubkeys.length > 2 - const recipients = remove($session?.pubkey, pubkeys) const pubkeysWithoutInbox = derived(inboxRelaySelectionsByPubkey, $inboxRelayPoliciesByPubkey => pubkeys.filter(pubkey => !$inboxRelayPoliciesByPubkey.has(pubkey)), ) - let useNip17 = isGroupMessage || ($hasNip44 && $pubkeysWithoutInbox.length === 0) - onMount(() => { editor = new Editor( getEditorOptions({ @@ -119,7 +113,7 @@ } const sendOrConfirm = () => { - if (isGroupMessage && $pubkeysWithoutInbox.length > 0) { + if ($pubkeysWithoutInbox.length > 0) { openConfirm() } else { send() @@ -132,7 +126,7 @@ if (content) { sending = true - await sendMessage(content, useNip17) + await sendMessage(content) sending = false stickToBottom() @@ -141,7 +135,6 @@ } $: userHasInbox = !$pubkeysWithoutInbox.includes($session?.pubkey) - $: hasSingleRecipientWithInbox = !isGroupMessage && !$pubkeysWithoutInbox.includes(recipients[0]) // Group messages so we're only showing the person once per chunk $: { @@ -247,7 +240,7 @@
End of message history
{/await}
- {#if $hasNip44 || !isGroupMessage} + {#if $hasNip44}
- {#if $hasNip44 && hasSingleRecipientWithInbox} -
- {#if userHasInbox} - - {:else} - -
- -
- - - You must have at least one inbox relay to send messages using nip-17. Click here to set - up your inbox relays. - -
- {/if} - - Send messages using - - NIP 17 -
-

- When enabled, Coracle will use nostr's new group chat specification, which solves - several problems with legacy DMs. Read more here. -

-

- Note that these messages are not yet universally supported. Make sure the person - you're chatting with is using a compatible nostr client. -

-
-
-
-
- {/if}
{:else} @@ -332,8 +287,7 @@

{displayList($pubkeysWithoutInbox.map(displayProfileByPubkey))} {pluralize($pubkeysWithoutInbox.length, "does not have", "do not have")} - inbox relays, which means they likely either don't want to receive DMs, or are using a client - that does not support nostr group chats. + inbox relays, which means they likely don't want to receive DMs.

{:else if !userHasInbox}