From 29bb33c26c7e5b58b06d1830083046aef8dd208d Mon Sep 17 00:00:00 2001 From: userAdityaa Date: Fri, 10 Apr 2026 22:56:48 +0545 Subject: [PATCH] publish kind 9 quote after room content creation for cross-client interoperability --- src/app.css | 2 +- src/app/components/CalendarEventCreate.svelte | 5 +- src/app/components/CalendarEventForm.svelte | 67 +++++++++++------ src/app/components/ClassifiedCreate.svelte | 5 +- src/app/components/ClassifiedForm.svelte | 23 ++++-- src/app/components/ComposeMenu.svelte | 10 +-- src/app/components/ContentQuote.svelte | 2 +- src/app/components/EventReply.svelte | 4 +- src/app/components/GoalCreate.svelte | 75 ++++++++++++------- src/app/components/NoteCard.svelte | 4 +- src/app/components/PollCreate.svelte | 56 ++++++++++---- src/app/components/ProfileBadges.svelte | 6 +- src/app/components/RoomItemContent.svelte | 9 +-- src/app/components/ThreadCreate.svelte | 67 +++++++++++------ src/app/core/commands.ts | 29 +++++++ src/app/core/state.ts | 2 - src/app/core/sync.ts | 6 +- src/app/util/notifications.ts | 6 +- src/app/util/push/adapters/common.ts | 9 ++- src/lib/components/Button.svelte | 2 +- src/lib/components/VirtualItem.svelte | 11 +-- src/routes/spaces/[relay]/[h]/+page.svelte | 3 +- src/routes/spaces/[relay]/chat/+page.svelte | 4 +- 23 files changed, 273 insertions(+), 134 deletions(-) diff --git a/src/app.css b/src/app.css index fa0b8a76..e36458bd 100644 --- a/src/app.css +++ b/src/app.css @@ -327,7 +327,7 @@ .note-editor .tiptap { --tiptap-object-bg: var(--color-base-200); - @apply input rounded-box h-auto min-h-32 p-[.65rem] pb-6; + @apply input rounded-box block h-auto min-h-32 w-full p-[.65rem] pb-6; } .input-editor .tiptap { diff --git a/src/app/components/CalendarEventCreate.svelte b/src/app/components/CalendarEventCreate.svelte index 25dc189a..2c9a325b 100644 --- a/src/app/components/CalendarEventCreate.svelte +++ b/src/app/components/CalendarEventCreate.svelte @@ -7,12 +7,13 @@ type Props = { url: string h?: string + shareToChat?: boolean } - const {url, h}: Props = $props() + const {url, h, shareToChat = false}: Props = $props() - + {#snippet header()} Create an Event diff --git a/src/app/components/CalendarEventForm.svelte b/src/app/components/CalendarEventForm.svelte index c67c6fd7..1f57c8c0 100644 --- a/src/app/components/CalendarEventForm.svelte +++ b/src/app/components/CalendarEventForm.svelte @@ -3,7 +3,7 @@ import {writable} from "svelte/store" import {randomId, HOUR} from "@welshman/lib" import {makeEvent, EVENT_TIME} from "@welshman/util" - import {publishThunk} from "@welshman/app" + import {publishThunk, waitForThunkError} from "@welshman/app" import {preventDefault} from "@lib/html" import {daysBetween} from "@lib/util" import GallerySend from "@assets/icons/gallery-send.svg?dataurl" @@ -22,7 +22,7 @@ import {makeEditor} from "@app/editor" import {DraftKey} from "@app/util/drafts" import {pushToast} from "@app/util/toast" - import {canEnforceNip70} from "@app/core/commands" + import {canEnforceNip70, publishRoomQuote} from "@app/core/commands" type Values = { d: string @@ -36,11 +36,12 @@ type Props = { url: string h?: string + shareToChat?: boolean header: Snippet initialValues?: Values } - let {url, h, header, initialValues}: Props = $props() + let {url, h, shareToChat = false, header, initialValues}: Props = $props() const draftKey = new DraftKey(`calendar:${url}:${h ?? ""}`) @@ -57,7 +58,7 @@ const selectFiles = () => editor.then(ed => ed.chain().selectFiles().run()) const submit = async () => { - if ($uploading) return + if ($uploading || loading) return if (!title) { return pushToast({ @@ -92,22 +93,42 @@ ...ed.storage.nostr.getEditorTags(), ] - if (await shouldProtect) { - tags.push(PROTECTED) + loading = true + + try { + const protect = await shouldProtect + + if (protect) { + tags.push(PROTECTED) + } + + if (h) { + tags.push(["h", h]) + } + + const event = makeEvent(EVENT_TIME, {content, tags}) + const calendarThunk = publishThunk({event, relays: [url]}) + const error = await waitForThunkError(calendarThunk) + + if (error) { + return pushToast({theme: "error", message: error}) + } + + draftKey.clear() + history.back() + + if (shareToChat) { + publishRoomQuote({url, h, parent: calendarThunk.event, protect}) + } + + pushToast({message: "Your event has been saved!"}) + } finally { + loading = false } - - if (h) { - tags.push(["h", h]) - } - - const event = makeEvent(EVENT_TIME, {content, tags}) - - pushToast({message: "Your event has been saved!"}) - publishThunk({event, relays: [url]}) - draftKey.clear() - history.back() } + let loading = $state(false) + const d = $state(initialValues?.d ?? randomId()) let title = $state(initialValues?.title ?? "") let location = $state(initialValues?.location ?? "") @@ -158,7 +179,11 @@
- - diff --git a/src/app/components/ClassifiedCreate.svelte b/src/app/components/ClassifiedCreate.svelte index da47115c..3a26def2 100644 --- a/src/app/components/ClassifiedCreate.svelte +++ b/src/app/components/ClassifiedCreate.svelte @@ -7,12 +7,13 @@ type Props = { url: string h?: string + shareToChat?: boolean } - const {url, h}: Props = $props() + const {url, h, shareToChat = false}: Props = $props() - + {#snippet header()} Create a Classified Listing diff --git a/src/app/components/ClassifiedForm.svelte b/src/app/components/ClassifiedForm.svelte index 28b33605..961fbd77 100644 --- a/src/app/components/ClassifiedForm.svelte +++ b/src/app/components/ClassifiedForm.svelte @@ -2,7 +2,7 @@ import type {Snippet} from "svelte" import {removeUndefined, randomId, uniq} from "@welshman/lib" import {makeEvent, CLASSIFIED} from "@welshman/util" - import {publishThunk} from "@welshman/app" + import {publishThunk, waitForThunkError} from "@welshman/app" import {isMobile, preventDefault} from "@lib/html" import {normalizeTopic} from "@lib/util" import AltArrowLeft from "@assets/icons/alt-arrow-left.svg?dataurl" @@ -21,7 +21,7 @@ import {PROTECTED} from "@app/core/state" import {makeEditor} from "@app/editor" import {DraftKey} from "@app/util/drafts" - import {canEnforceNip70, uploadFile} from "@app/core/commands" + import {canEnforceNip70, publishRoomQuote, uploadFile} from "@app/core/commands" type Values = { d: string @@ -37,11 +37,12 @@ type Props = { url: string h?: string + shareToChat?: boolean header: Snippet initialValues?: Values } - let {url, h, header, initialValues}: Props = $props() + let {url, h, shareToChat = false, header, initialValues}: Props = $props() const draftKey = new DraftKey(`classified:${url}:${h ?? ""}`) @@ -87,7 +88,9 @@ tags.push(["t", topic]) } - if (await shouldProtect) { + const protect = await shouldProtect + + if (protect) { tags.push(PROTECTED) } @@ -114,13 +117,23 @@ } } - publishThunk({ + const classifiedThunk = publishThunk({ relays: [url], event: makeEvent(CLASSIFIED, {content, tags}), }) + const error = await waitForThunkError(classifiedThunk) + + if (error) { + return pushToast({theme: "error", message: error}) + } + draftKey.clear() history.back() + + if (shareToChat) { + publishRoomQuote({url, h, parent: classifiedThunk.event, protect}) + } } finally { loading = false } diff --git a/src/app/components/ComposeMenu.svelte b/src/app/components/ComposeMenu.svelte index b7828d55..408f3f95 100644 --- a/src/app/components/ComposeMenu.svelte +++ b/src/app/components/ComposeMenu.svelte @@ -22,15 +22,15 @@ const {url, h, onClick}: Props = $props() - const createGoal = () => pushModal(GoalCreate, {url, h}) + const createGoal = () => pushModal(GoalCreate, {url, h, shareToChat: true}) - const createCalendarEvent = () => pushModal(CalendarEventCreate, {url, h}) + const createCalendarEvent = () => pushModal(CalendarEventCreate, {url, h, shareToChat: true}) - const createThread = () => pushModal(ThreadCreate, {url, h}) + const createThread = () => pushModal(ThreadCreate, {url, h, shareToChat: true}) - const createClassified = () => pushModal(ClassifiedCreate, {url, h}) + const createClassified = () => pushModal(ClassifiedCreate, {url, h, shareToChat: true}) - const createPoll = () => pushModal(PollCreate, {url, h}) + const createPoll = () => pushModal(PollCreate, {url, h, shareToChat: true}) let ul: Element diff --git a/src/app/components/ContentQuote.svelte b/src/app/components/ContentQuote.svelte index 6d42d3f3..f36993f8 100644 --- a/src/app/components/ContentQuote.svelte +++ b/src/app/components/ContentQuote.svelte @@ -49,7 +49,7 @@ {:else} - + {/if} diff --git a/src/app/components/EventReply.svelte b/src/app/components/EventReply.svelte index fd29ee54..d7377826 100644 --- a/src/app/components/EventReply.svelte +++ b/src/app/components/EventReply.svelte @@ -68,7 +68,7 @@ }) const observer = new ResizeObserver(() => { - spacer!.style.minHeight = `${form!.offsetHeight}px` + spacer!.style.minHeight = `${form!.offsetHeight + 60}px` }) observer.observe(form!) @@ -84,7 +84,7 @@ in:fly bind:this={form} onsubmit={preventDefault(submit)} - class="left-content bottom-sai right-sai ml-2 pl-2 fixed z-feature"> + class="left-content bottom-sai right-sai fixed z-feature mb-14 md:mb-0 w-full md:w-auto pr-2">
diff --git a/src/app/components/GoalCreate.svelte b/src/app/components/GoalCreate.svelte index 3854443e..3359f007 100644 --- a/src/app/components/GoalCreate.svelte +++ b/src/app/components/GoalCreate.svelte @@ -1,7 +1,7 @@ -
+
{#if muted}
diff --git a/src/app/components/PollCreate.svelte b/src/app/components/PollCreate.svelte index bd2e0849..5a60e68e 100644 --- a/src/app/components/PollCreate.svelte +++ b/src/app/components/PollCreate.svelte @@ -1,7 +1,7 @@
diff --git a/src/app/components/ThreadCreate.svelte b/src/app/components/ThreadCreate.svelte index 61ead197..fc68a95e 100644 --- a/src/app/components/ThreadCreate.svelte +++ b/src/app/components/ThreadCreate.svelte @@ -1,13 +1,14 @@