Fix missing compose input, handle parents differently
This commit is contained in:
+20
-1
@@ -1,3 +1,4 @@
|
|||||||
|
import * as nip19 from "nostr-tools/nip19"
|
||||||
import {get} from "svelte/store"
|
import {get} from "svelte/store"
|
||||||
import {ctx, sample, uniq, sleep, chunk, equals} from "@welshman/lib"
|
import {ctx, sample, uniq, sleep, chunk, equals} from "@welshman/lib"
|
||||||
import {
|
import {
|
||||||
@@ -27,8 +28,9 @@ import {
|
|||||||
getRelayTags,
|
getRelayTags,
|
||||||
isShareableRelayUrl,
|
isShareableRelayUrl,
|
||||||
getRelayTagValues,
|
getRelayTagValues,
|
||||||
|
toNostrURI,
|
||||||
} from "@welshman/util"
|
} from "@welshman/util"
|
||||||
import type {TrustedEvent, EventTemplate, List} from "@welshman/util"
|
import type {TrustedEvent, EventContent, EventTemplate, List} from "@welshman/util"
|
||||||
import type {SubscribeRequestWithHandlers} from "@welshman/net"
|
import type {SubscribeRequestWithHandlers} from "@welshman/net"
|
||||||
import {PublishStatus, AuthStatus, SocketStatus} from "@welshman/net"
|
import {PublishStatus, AuthStatus, SocketStatus} from "@welshman/net"
|
||||||
import {Nip59, makeSecret, stamp, Nip46Broker} from "@welshman/signer"
|
import {Nip59, makeSecret, stamp, Nip46Broker} from "@welshman/signer"
|
||||||
@@ -56,6 +58,7 @@ import {
|
|||||||
clearStorage,
|
clearStorage,
|
||||||
dropSession,
|
dropSession,
|
||||||
tagEventForComment,
|
tagEventForComment,
|
||||||
|
tagEventForQuote,
|
||||||
} from "@welshman/app"
|
} from "@welshman/app"
|
||||||
import type {Thunk} from "@welshman/app"
|
import type {Thunk} from "@welshman/app"
|
||||||
import {
|
import {
|
||||||
@@ -96,6 +99,22 @@ export const getThunkError = async (thunk: Thunk) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const prependParent = (parent: TrustedEvent | undefined, {content, tags}: EventContent) => {
|
||||||
|
if (parent) {
|
||||||
|
const nevent = nip19.neventEncode({
|
||||||
|
id: parent.id,
|
||||||
|
kind: parent.kind,
|
||||||
|
author: parent.pubkey,
|
||||||
|
relays: ctx.app.router.Event(parent).limit(3).getUrls(),
|
||||||
|
})
|
||||||
|
|
||||||
|
tags = [...tags, tagEventForQuote(parent)]
|
||||||
|
content = toNostrURI(nevent) + "\n\n" + content
|
||||||
|
}
|
||||||
|
|
||||||
|
return {content, tags}
|
||||||
|
}
|
||||||
|
|
||||||
// Log in
|
// Log in
|
||||||
|
|
||||||
export const loginWithNip46 = async ({
|
export const loginWithNip46 = async ({
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {onMount} from "svelte"
|
import {onMount} from "svelte"
|
||||||
import {writable} from "svelte/store"
|
import {writable} from "svelte/store"
|
||||||
|
import {EditorContent} from "svelte-tiptap"
|
||||||
import {isMobile} from "@lib/html"
|
import {isMobile} from "@lib/html"
|
||||||
import Icon from "@lib/components/Icon.svelte"
|
import Icon from "@lib/components/Icon.svelte"
|
||||||
import Button from "@lib/components/Button.svelte"
|
import Button from "@lib/components/Button.svelte"
|
||||||
import {getEditor} from "@app/editor"
|
import {makeEditor} from "@app/editor"
|
||||||
|
|
||||||
export let onSubmit: any
|
export let onSubmit: any
|
||||||
export let content = ""
|
export let content = ""
|
||||||
export let editor: ReturnType<typeof getEditor> | undefined = undefined
|
|
||||||
|
export const focus = () => $editor.chain().focus().run()
|
||||||
|
|
||||||
const uploading = writable(false)
|
const uploading = writable(false)
|
||||||
|
|
||||||
let element: HTMLElement
|
|
||||||
|
|
||||||
const uploadFiles = () => $editor!.chain().selectFiles().run()
|
const uploadFiles = () => $editor!.chain().selectFiles().run()
|
||||||
|
|
||||||
const submit = () => {
|
const submit = () => {
|
||||||
@@ -29,9 +29,9 @@
|
|||||||
$editor!.chain().clearContent().run()
|
$editor!.chain().clearContent().run()
|
||||||
}
|
}
|
||||||
|
|
||||||
onMount(() => {
|
const editor = makeEditor({autofocus: !isMobile, submit, uploading, aggressive: true})
|
||||||
editor = getEditor({autofocus: !isMobile, element, submit, uploading, aggressive: true})
|
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
$editor!.chain().setContent(content).run()
|
$editor!.chain().setContent(content).run()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
@@ -51,7 +51,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</Button>
|
</Button>
|
||||||
<div class="chat-editor flex-grow overflow-hidden">
|
<div class="chat-editor flex-grow overflow-hidden">
|
||||||
<div bind:this={element} />
|
<EditorContent editor={$editor} />
|
||||||
</div>
|
</div>
|
||||||
<Button
|
<Button
|
||||||
data-tip="{window.navigator.platform.includes('Mac') ? 'cmd' : 'ctrl'}+enter to send"
|
data-tip="{window.navigator.platform.includes('Mac') ? 'cmd' : 'ctrl'}+enter to send"
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import type {TrustedEvent} from "@welshman/util"
|
||||||
|
import {displayProfileByPubkey} from "@welshman/app"
|
||||||
|
import {slide} from "@lib/transition"
|
||||||
|
import Icon from "@lib/components/Icon.svelte"
|
||||||
|
import Button from "@lib/components/Button.svelte"
|
||||||
|
import Content from "@app/components/Content.svelte"
|
||||||
|
|
||||||
|
export let event: TrustedEvent
|
||||||
|
export let clear: () => void
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="relative border-l-2 border-solid border-primary bg-base-300 px-2 py-1 pr-8 text-xs"
|
||||||
|
transition:slide>
|
||||||
|
<p class="text-primary">Replying to @{displayProfileByPubkey(event.pubkey)}</p>
|
||||||
|
{#key event.id}
|
||||||
|
<Content {event} minLength={100} maxLength={300} expandMode="disabled" />
|
||||||
|
{/key}
|
||||||
|
<Button class="absolute right-2 top-2 cursor-pointer" on:click={clear}>
|
||||||
|
<Icon icon="close-circle" />
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
@@ -10,19 +10,10 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {onMount} from "svelte"
|
import {onMount} from "svelte"
|
||||||
import {derived} from "svelte/store"
|
import {derived} from "svelte/store"
|
||||||
import type {Readable} from "svelte/store"
|
import {int, nthNe, MINUTE, sortBy, remove} from "@welshman/lib"
|
||||||
import type {Editor} from "svelte-tiptap"
|
|
||||||
import {nip19} from "nostr-tools"
|
|
||||||
import {int, nthNe, MINUTE, sortBy, remove, ctx} from "@welshman/lib"
|
|
||||||
import type {TrustedEvent, EventContent} from "@welshman/util"
|
import type {TrustedEvent, EventContent} from "@welshman/util"
|
||||||
import {createEvent, DIRECT_MESSAGE, INBOX_RELAYS} from "@welshman/util"
|
import {createEvent, DIRECT_MESSAGE, INBOX_RELAYS} from "@welshman/util"
|
||||||
import {
|
import {pubkey, formatTimestampAsDate, inboxRelaySelectionsByPubkey, load} from "@welshman/app"
|
||||||
pubkey,
|
|
||||||
formatTimestampAsDate,
|
|
||||||
inboxRelaySelectionsByPubkey,
|
|
||||||
load,
|
|
||||||
tagPubkey,
|
|
||||||
} from "@welshman/app"
|
|
||||||
import Icon from "@lib/components/Icon.svelte"
|
import Icon from "@lib/components/Icon.svelte"
|
||||||
import Link from "@lib/components/Link.svelte"
|
import Link from "@lib/components/Link.svelte"
|
||||||
import Spinner from "@lib/components/Spinner.svelte"
|
import Spinner from "@lib/components/Spinner.svelte"
|
||||||
@@ -36,9 +27,10 @@
|
|||||||
import ProfileList from "@app/components/ProfileList.svelte"
|
import ProfileList from "@app/components/ProfileList.svelte"
|
||||||
import ChatMessage from "@app/components/ChatMessage.svelte"
|
import ChatMessage from "@app/components/ChatMessage.svelte"
|
||||||
import ChatCompose from "@app/components/ChannelCompose.svelte"
|
import ChatCompose from "@app/components/ChannelCompose.svelte"
|
||||||
|
import ChatComposeParent from "@app/components/ChannelComposeParent.svelte"
|
||||||
import {userSettingValues, deriveChat, splitChatId, PLATFORM_NAME} from "@app/state"
|
import {userSettingValues, deriveChat, splitChatId, PLATFORM_NAME} from "@app/state"
|
||||||
import {pushModal} from "@app/modal"
|
import {pushModal} from "@app/modal"
|
||||||
import {sendWrapped} from "@app/commands"
|
import {sendWrapped, prependParent} from "@app/commands"
|
||||||
|
|
||||||
export let id
|
export let id
|
||||||
|
|
||||||
@@ -57,28 +49,31 @@
|
|||||||
pushModal(ProfileList, {pubkeys: others, title: `People in this conversation`})
|
pushModal(ProfileList, {pubkeys: others, title: `People in this conversation`})
|
||||||
|
|
||||||
const replyTo = (event: TrustedEvent) => {
|
const replyTo = (event: TrustedEvent) => {
|
||||||
const relays = ctx.app.router.Event(event).getUrls()
|
parent = event
|
||||||
const bech32 = nip19.neventEncode({...event, relays})
|
compose.focus()
|
||||||
|
|
||||||
$editor.commands.insertNEvent({bech32})
|
|
||||||
$editor.commands.insertContent("\n")
|
|
||||||
$editor.commands.focus()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const onSubmit = async ({content, ...params}: EventContent) => {
|
const clearParent = () => {
|
||||||
// Remove p tags since they result in forking the conversation
|
parent = undefined
|
||||||
const tags = [...params.tags.filter(nthNe(0, "p")), ...remove($pubkey!, pubkeys).map(tagPubkey)]
|
}
|
||||||
|
|
||||||
|
const onSubmit = async ({content, tags}: EventContent) => {
|
||||||
await sendWrapped({
|
await sendWrapped({
|
||||||
pubkeys,
|
pubkeys,
|
||||||
template: createEvent(DIRECT_MESSAGE, {content, tags}),
|
template: createEvent(
|
||||||
|
DIRECT_MESSAGE,
|
||||||
|
prependParent(parent, {content, tags: tags.filter(nthNe(0, "p"))}),
|
||||||
|
),
|
||||||
delay: $userSettingValues.send_delay,
|
delay: $userSettingValues.send_delay,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
clearParent()
|
||||||
}
|
}
|
||||||
|
|
||||||
let loading = true
|
let loading = true
|
||||||
let editor: Readable<Editor>
|
let parent: TrustedEvent | undefined
|
||||||
let elements: Element[] = []
|
let elements: Element[] = []
|
||||||
|
let compose: ChatCompose
|
||||||
|
|
||||||
$: {
|
$: {
|
||||||
elements = []
|
elements = []
|
||||||
@@ -200,5 +195,8 @@
|
|||||||
<slot name="info" />
|
<slot name="info" />
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<ChatCompose bind:editor {onSubmit} />
|
{#if parent}
|
||||||
|
<ChatComposeParent event={parent} clear={clearParent} />
|
||||||
|
{/if}
|
||||||
|
<ChatCompose bind:this={compose} {onSubmit} />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -93,7 +93,7 @@
|
|||||||
mediaLength: hideMedia ? 20 : 200,
|
mediaLength: hideMedia ? 20 : 200,
|
||||||
})
|
})
|
||||||
|
|
||||||
$: hasEllipsis = shortContent.find(isEllipsis)
|
$: hasEllipsis = shortContent.some(isEllipsis)
|
||||||
$: expandInline = hasEllipsis && expandMode === "inline"
|
$: expandInline = hasEllipsis && expandMode === "inline"
|
||||||
$: expandBlock = hasEllipsis && expandMode === "block"
|
$: expandBlock = hasEllipsis && expandMode === "block"
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {onMount} from "svelte"
|
import {EditorContent} from "svelte-tiptap"
|
||||||
import {writable} from "svelte/store"
|
import {writable} from "svelte/store"
|
||||||
import {randomId} from "@welshman/lib"
|
import {randomId} from "@welshman/lib"
|
||||||
import {createEvent, EVENT_TIME} from "@welshman/util"
|
import {createEvent, EVENT_TIME} from "@welshman/util"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
||||||
import DateTimeInput from "@lib/components/DateTimeInput.svelte"
|
import DateTimeInput from "@lib/components/DateTimeInput.svelte"
|
||||||
import {PROTECTED} from "@app/state"
|
import {PROTECTED} from "@app/state"
|
||||||
import {getEditor} from "@app/editor"
|
import {makeEditor} from "@app/editor"
|
||||||
import {pushToast} from "@app/toast"
|
import {pushToast} from "@app/toast"
|
||||||
|
|
||||||
export let url
|
export let url
|
||||||
@@ -54,16 +54,12 @@
|
|||||||
history.back()
|
history.back()
|
||||||
}
|
}
|
||||||
|
|
||||||
let element: HTMLElement
|
const editor = makeEditor({submit, uploading})
|
||||||
let editor: ReturnType<typeof getEditor>
|
|
||||||
let title = ""
|
let title = ""
|
||||||
let location = ""
|
let location = ""
|
||||||
let start: Date
|
let start: Date
|
||||||
let end: Date
|
let end: Date
|
||||||
|
|
||||||
onMount(() => {
|
|
||||||
editor = getEditor({submit, element, uploading})
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<form class="column gap-4" on:submit|preventDefault={submit}>
|
<form class="column gap-4" on:submit|preventDefault={submit}>
|
||||||
@@ -83,7 +79,7 @@
|
|||||||
slot="input"
|
slot="input"
|
||||||
class="relative z-feature flex gap-2 border-t border-solid border-base-100 bg-base-100">
|
class="relative z-feature flex gap-2 border-t border-solid border-base-100 bg-base-100">
|
||||||
<div class="input-editor flex-grow overflow-hidden">
|
<div class="input-editor flex-grow overflow-hidden">
|
||||||
<div bind:this={element} />
|
<EditorContent editor={$editor} />
|
||||||
</div>
|
</div>
|
||||||
<Button
|
<Button
|
||||||
data-tip="Add an image"
|
data-tip="Add an image"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {onMount} from "svelte"
|
|
||||||
import {writable} from "svelte/store"
|
import {writable} from "svelte/store"
|
||||||
|
import {EditorContent} from "svelte-tiptap"
|
||||||
import {createEvent, THREAD} from "@welshman/util"
|
import {createEvent, THREAD} from "@welshman/util"
|
||||||
import {publishThunk} from "@welshman/app"
|
import {publishThunk} from "@welshman/app"
|
||||||
import {isMobile} from "@lib/html"
|
import {isMobile} from "@lib/html"
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
||||||
import {pushToast} from "@app/toast"
|
import {pushToast} from "@app/toast"
|
||||||
import {GENERAL, tagRoom, PROTECTED} from "@app/state"
|
import {GENERAL, tagRoom, PROTECTED} from "@app/state"
|
||||||
import {getEditor} from "@app/editor"
|
import {makeEditor} from "@app/editor"
|
||||||
|
|
||||||
export let url
|
export let url
|
||||||
|
|
||||||
@@ -53,13 +53,9 @@
|
|||||||
history.back()
|
history.back()
|
||||||
}
|
}
|
||||||
|
|
||||||
let title: string
|
const editor = makeEditor({submit, uploading, placeholder: "What's on your mind?"})
|
||||||
let element: HTMLElement
|
|
||||||
let editor: ReturnType<typeof getEditor>
|
|
||||||
|
|
||||||
onMount(() => {
|
let title: string
|
||||||
editor = getEditor({submit, element, uploading, placeholder: "What's on your mind?"})
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<form class="column gap-4" on:submit|preventDefault={submit}>
|
<form class="column gap-4" on:submit|preventDefault={submit}>
|
||||||
@@ -83,7 +79,7 @@
|
|||||||
<Field>
|
<Field>
|
||||||
<p slot="label">Message*</p>
|
<p slot="label">Message*</p>
|
||||||
<div slot="input" class="note-editor flex-grow overflow-hidden">
|
<div slot="input" class="note-editor flex-grow overflow-hidden">
|
||||||
<div bind:this={element} />
|
<EditorContent editor={$editor} />
|
||||||
</div>
|
</div>
|
||||||
</Field>
|
</Field>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {onMount} from "svelte"
|
|
||||||
import {writable} from "svelte/store"
|
import {writable} from "svelte/store"
|
||||||
|
import {EditorContent} from "svelte-tiptap"
|
||||||
import {isMobile} from "@lib/html"
|
import {isMobile} from "@lib/html"
|
||||||
import {fly, slideAndFade} from "@lib/transition"
|
import {fly, slideAndFade} from "@lib/transition"
|
||||||
import Icon from "@lib/components/Icon.svelte"
|
import Icon from "@lib/components/Icon.svelte"
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
||||||
import {publishComment} from "@app/commands"
|
import {publishComment} from "@app/commands"
|
||||||
import {tagRoom, GENERAL, PROTECTED} from "@app/state"
|
import {tagRoom, GENERAL, PROTECTED} from "@app/state"
|
||||||
import {getEditor} from "@app/editor"
|
import {makeEditor} from "@app/editor"
|
||||||
import {pushToast} from "@app/toast"
|
import {pushToast} from "@app/toast"
|
||||||
|
|
||||||
export let url
|
export let url
|
||||||
@@ -34,12 +34,7 @@
|
|||||||
onSubmit(publishComment({event, content, tags, relays: [url]}))
|
onSubmit(publishComment({event, content, tags, relays: [url]}))
|
||||||
}
|
}
|
||||||
|
|
||||||
let editor: ReturnType<typeof getEditor>
|
const editor = makeEditor({submit, uploading, autofocus: !isMobile})
|
||||||
let element: HTMLElement
|
|
||||||
|
|
||||||
onMount(() => {
|
|
||||||
editor = getEditor({element, submit, uploading, autofocus: !isMobile})
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<form
|
<form
|
||||||
@@ -49,7 +44,7 @@
|
|||||||
class="card2 sticky bottom-2 z-feature mx-2 mt-4 bg-neutral">
|
class="card2 sticky bottom-2 z-feature mx-2 mt-4 bg-neutral">
|
||||||
<div class="relative">
|
<div class="relative">
|
||||||
<div class="note-editor flex-grow overflow-hidden">
|
<div class="note-editor flex-grow overflow-hidden">
|
||||||
<div bind:this={element} />
|
<EditorContent editor={$editor} />
|
||||||
</div>
|
</div>
|
||||||
<Button
|
<Button
|
||||||
data-tip="Add an image"
|
data-tip="Add an image"
|
||||||
|
|||||||
@@ -25,12 +25,11 @@ export const signWithAssert = async (template: StampedEvent) => {
|
|||||||
return event!
|
return event!
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getEditor = ({
|
export const makeEditor = ({
|
||||||
aggressive = false,
|
aggressive = false,
|
||||||
autofocus = false,
|
autofocus = false,
|
||||||
charCount,
|
charCount,
|
||||||
content = "",
|
content = "",
|
||||||
element,
|
|
||||||
placeholder = "",
|
placeholder = "",
|
||||||
submit,
|
submit,
|
||||||
uploading,
|
uploading,
|
||||||
@@ -40,14 +39,12 @@ export const getEditor = ({
|
|||||||
autofocus?: boolean
|
autofocus?: boolean
|
||||||
charCount?: Writable<number>
|
charCount?: Writable<number>
|
||||||
content?: string
|
content?: string
|
||||||
element: HTMLElement
|
|
||||||
placeholder?: string
|
placeholder?: string
|
||||||
submit: () => void
|
submit: () => void
|
||||||
uploading?: Writable<boolean>
|
uploading?: Writable<boolean>
|
||||||
wordCount?: Writable<number>
|
wordCount?: Writable<number>
|
||||||
}) =>
|
}) =>
|
||||||
createEditor({
|
createEditor({
|
||||||
element,
|
|
||||||
content,
|
content,
|
||||||
autofocus,
|
autofocus,
|
||||||
extensions: [
|
extensions: [
|
||||||
|
|||||||
@@ -1,31 +1,22 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import * as nip19 from "nostr-tools/nip19"
|
|
||||||
import {onMount} from "svelte"
|
import {onMount} from "svelte"
|
||||||
import {page} from "$app/stores"
|
import {page} from "$app/stores"
|
||||||
import type {Readable} from "svelte/store"
|
import type {Readable} from "svelte/store"
|
||||||
import {now, ctx} from "@welshman/lib"
|
import {now} from "@welshman/lib"
|
||||||
import type {TrustedEvent, EventContent} from "@welshman/util"
|
import type {TrustedEvent, EventContent} from "@welshman/util"
|
||||||
import {createEvent, toNostrURI, MESSAGE, DELETE, REACTION} from "@welshman/util"
|
import {createEvent, MESSAGE, DELETE, REACTION} from "@welshman/util"
|
||||||
import {
|
import {formatTimestampAsDate, publishThunk, deriveRelay, repository} from "@welshman/app"
|
||||||
displayProfileByPubkey,
|
|
||||||
formatTimestampAsDate,
|
|
||||||
tagEventForQuote,
|
|
||||||
publishThunk,
|
|
||||||
deriveRelay,
|
|
||||||
repository,
|
|
||||||
} from "@welshman/app"
|
|
||||||
import {slide, fade} from "@lib/transition"
|
import {slide, fade} from "@lib/transition"
|
||||||
import Icon from "@lib/components/Icon.svelte"
|
import Icon from "@lib/components/Icon.svelte"
|
||||||
import Button from "@lib/components/Button.svelte"
|
import Button from "@lib/components/Button.svelte"
|
||||||
import Spinner from "@lib/components/Spinner.svelte"
|
import Spinner from "@lib/components/Spinner.svelte"
|
||||||
import PageBar from "@lib/components/PageBar.svelte"
|
import PageBar from "@lib/components/PageBar.svelte"
|
||||||
import Divider from "@lib/components/Divider.svelte"
|
import Divider from "@lib/components/Divider.svelte"
|
||||||
import type {getEditor} from "@app/editor"
|
|
||||||
import MenuSpaceButton from "@app/components/MenuSpaceButton.svelte"
|
import MenuSpaceButton from "@app/components/MenuSpaceButton.svelte"
|
||||||
import Content from "@app/components/Content.svelte"
|
|
||||||
import ChannelName from "@app/components/ChannelName.svelte"
|
import ChannelName from "@app/components/ChannelName.svelte"
|
||||||
import ChannelMessage from "@app/components/ChannelMessage.svelte"
|
import ChannelMessage from "@app/components/ChannelMessage.svelte"
|
||||||
import ChannelCompose from "@app/components/ChannelCompose.svelte"
|
import ChannelCompose from "@app/components/ChannelCompose.svelte"
|
||||||
|
import ChannelComposeParent from "@app/components/ChannelComposeParent.svelte"
|
||||||
import {
|
import {
|
||||||
userSettingValues,
|
userSettingValues,
|
||||||
decodeRelay,
|
decodeRelay,
|
||||||
@@ -36,7 +27,13 @@
|
|||||||
getEventsForUrl,
|
getEventsForUrl,
|
||||||
} from "@app/state"
|
} from "@app/state"
|
||||||
import {setChecked} from "@app/notifications"
|
import {setChecked} from "@app/notifications"
|
||||||
import {nip29, addRoomMembership, removeRoomMembership, getThunkError} from "@app/commands"
|
import {
|
||||||
|
nip29,
|
||||||
|
addRoomMembership,
|
||||||
|
removeRoomMembership,
|
||||||
|
prependParent,
|
||||||
|
getThunkError,
|
||||||
|
} from "@app/commands"
|
||||||
import {PROTECTED, hasNip29} from "@app/state"
|
import {PROTECTED, hasNip29} from "@app/state"
|
||||||
import {makeFeed} from "@app/requests"
|
import {makeFeed} from "@app/requests"
|
||||||
import {popKey} from "@app/implicit"
|
import {popKey} from "@app/implicit"
|
||||||
@@ -72,6 +69,7 @@
|
|||||||
|
|
||||||
const replyTo = (event: TrustedEvent) => {
|
const replyTo = (event: TrustedEvent) => {
|
||||||
parent = event
|
parent = event
|
||||||
|
compose.focus()
|
||||||
}
|
}
|
||||||
|
|
||||||
const clearParent = () => {
|
const clearParent = () => {
|
||||||
@@ -82,23 +80,13 @@
|
|||||||
tags.push(tagRoom(room, url))
|
tags.push(tagRoom(room, url))
|
||||||
tags.push(PROTECTED)
|
tags.push(PROTECTED)
|
||||||
|
|
||||||
if (parent) {
|
|
||||||
const nevent = nip19.neventEncode({
|
|
||||||
id: parent.id,
|
|
||||||
kind: parent.kind,
|
|
||||||
author: parent.pubkey,
|
|
||||||
relays: ctx.app.router.Event(parent).limit(3).getUrls(),
|
|
||||||
})
|
|
||||||
|
|
||||||
tags.push(tagEventForQuote(parent))
|
|
||||||
content = toNostrURI(nevent) + "\n\n" + content
|
|
||||||
}
|
|
||||||
|
|
||||||
publishThunk({
|
publishThunk({
|
||||||
relays: [url],
|
relays: [url],
|
||||||
event: createEvent(MESSAGE, {content, tags}),
|
event: createEvent(MESSAGE, prependParent(parent, {content, tags})),
|
||||||
delay: $userSettingValues.send_delay,
|
delay: $userSettingValues.send_delay,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
clearParent()
|
||||||
}
|
}
|
||||||
|
|
||||||
const scrollToBottom = () => element.scrollTo({top: 0, behavior: "smooth"})
|
const scrollToBottom = () => element.scrollTo({top: 0, behavior: "smooth"})
|
||||||
@@ -107,9 +95,9 @@
|
|||||||
let loading = true
|
let loading = true
|
||||||
let element: HTMLElement
|
let element: HTMLElement
|
||||||
let showScrollButton = false
|
let showScrollButton = false
|
||||||
let editor: ReturnType<typeof getEditor>
|
|
||||||
let cleanup: () => void
|
let cleanup: () => void
|
||||||
let events: Readable<TrustedEvent[]>
|
let events: Readable<TrustedEvent[]>
|
||||||
|
let compose: ChannelCompose
|
||||||
let elements: any[] = []
|
let elements: any[] = []
|
||||||
|
|
||||||
$: {
|
$: {
|
||||||
@@ -223,17 +211,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
{#if parent}
|
{#if parent}
|
||||||
<div
|
<ChannelComposeParent event={parent} clear={clearParent} />
|
||||||
class="relative border-l-2 border-solid border-primary bg-base-300 px-2 py-1 text-xs"
|
|
||||||
transition:slide>
|
|
||||||
<p class="text-primary">Replying to @{displayProfileByPubkey(parent.pubkey)}</p>
|
|
||||||
<Content event={parent} minLength={30} maxLength={200} />
|
|
||||||
<Button class="absolute right-2 top-2 cursor-pointer" on:click={clearParent}>
|
|
||||||
<Icon icon="close-circle" />
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
{/if}
|
{/if}
|
||||||
<ChannelCompose bind:editor {content} {onSubmit} />
|
<ChannelCompose bind:this={compose} {content} {onSubmit} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user