diff --git a/ROADMAP.md b/ROADMAP.md index 9dc75c05..fd32e558 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -3,6 +3,7 @@ - [ ] Refactor - Split out Note pieces - Move global modals to child components? + - Combine app/agent, rename app2 - [ ] Relays bounty - [ ] Ability to create custom feeds - [ ] Add global/following/network tabs to relay detail diff --git a/src/app2/shared/Note.svelte b/src/app2/shared/Note.svelte index 2ec21039..a163a381 100644 --- a/src/app2/shared/Note.svelte +++ b/src/app2/shared/Note.svelte @@ -1,22 +1,9 @@ - - {#if $person}
@@ -460,7 +380,7 @@ class={cx("flex", { "pointer-events-none opacity-75": !$canPublish || muted, })}> - @@ -527,67 +447,9 @@
- {#if reply} -
-
-
- - - -
- {#if image} -
- { - image = null - }} /> -
- {/if} -
-
-
-
- - - - -
-
-
- {#each replyMentions as p} -
-
- {:else} -
No mentions
- {/each} -
-
-
-
-
- - Posting as @{displayPerson(getPersonWithFallback(user.getPubkey()))} - -
-
- {/if} + - {#if !reply && visibleNotes.length > 0 && !showEntire && depth > 0 && !muted} + {#if !reply?.isActive() && visibleNotes.length > 0 && !showEntire && depth > 0 && !muted}
+ import {nip19} from "nostr-tools" + import {without, pluck, uniq} from "ramda" + import {slide} from "svelte/transition" + import {Tags, displayPerson} from "src/util/nostr" + import ImageInput from "src/partials/ImageInput.svelte" + import Media from "src/partials/Media.svelte" + import Compose from "src/partials/Compose.svelte" + import {getPersonWithFallback} from "src/agent/db" + import {getEventPublishRelays} from "src/agent/relays" + import user from "src/agent/user" + import cmd from "src/agent/cmd" + import {toast} from "src/app/ui" + import {publishWithToast} from "src/app" + + export let note + export let borderColor + + let data = null + let reply = null + let container = null + + export const isActive = () => Boolean(reply) + + export const start = () => { + data = { + image: null, + mentions: without( + [user.getPubkey()], + uniq(Tags.from(note).type("p").values().all().concat(note.pubkey)) + ), + } + } + + const reset = () => { + data = null + reply = null + } + + const removeMention = pubkey => { + data.mentions = without([pubkey], data.mentions) + } + + const send = async () => { + let {content, mentions, topics} = reply.parse() + + if (data.image) { + content = (content + "\n" + data.image).trim() + } + + if (content) { + mentions = uniq(mentions.concat(data.mentions)) + + const relays = getEventPublishRelays(note) + const thunk = cmd.createReply(note, content, mentions, topics) + const [event, promise] = await publishWithToast(relays, thunk) + + promise.then(({succeeded}) => { + if (succeeded.size > 0) { + toast.show("info", { + text: `Your note has been created!`, + link: { + text: "View", + href: + "/" + + nip19.neventEncode({ + id: event.id, + relays: pluck("url", relays.slice(0, 3)), + }), + }, + }) + } + }) + + reset() + } + } + + const onBodyClick = e => { + const target = e.target as HTMLElement + + if (container?.contains(target)) { + reset() + } + } + + + + +{#if data} +
+
+
+ + + +
+ {#if data.image} +
+ { + data.image = null + }} /> +
+ {/if} +
+
+
+
+ + + + +
+
+
+ {#each data.mentions as p} +
+
+ {:else} +
No mentions
+ {/each} +
+
+
+
+
+ + Posting as @{displayPerson(getPersonWithFallback(user.getPubkey()))} + +
+
+{/if}