From 79b8c26ac0a43b4dd185082f65531904dfc3a059 Mon Sep 17 00:00:00 2001 From: Alexander Lopatin Date: Tue, 16 Jul 2024 21:57:01 +0800 Subject: [PATCH] Improve workaround for https://github.com/franzaps/zapthreads/issues/50 --- src/reply.tsx | 9 ++++++--- src/thread.tsx | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/reply.tsx b/src/reply.tsx index a1d8321..f9f9b3e 100644 --- a/src/reply.tsx +++ b/src/reply.tsx @@ -8,13 +8,15 @@ import { generateSecretKey, getPublicKey, getEventHash, finalizeEvent } from "no import { createAutofocus } from "@solid-primitives/autofocus"; import { find, save, watch } from "./util/db.ts"; import { Profile, eventToNoteEvent } from "./util/models.ts"; +import { Signal, newSignal } from "./util/solidjs.ts"; import { lightningSvg, likeSvg, nostrSvg, warningSvg } from "./thread.tsx"; import { decode, npubEncode } from "nostr-tools/nip19"; import { Relay } from "nostr-tools/relay"; import { normalizeURL } from "nostr-tools/utils"; -export const ReplyEditor = (props: { replyTo?: string; onDone?: Function; }) => { - const [comment, setComment] = createSignal(''); +export const ReplyEditor = (props: { comment: Signal; replyTo?: string; onDone?: Function; }) => { + const comment = () => props.comment(); + const setComment = (text: string) => props.comment(text); const [loading, setLoading] = createSignal(false); const [loggedInUser, setLoggedInUser] = createSignal(); const [errorMessage, setErrorMessage] = createSignal(''); @@ -255,6 +257,7 @@ export const RootComment = () => { const likesAggregate = watch(() => ['aggregates', IDBKeyRange.only([anchor().value, 7])]); const zapCount = () => zapsAggregate()?.sum ?? 0; const likeCount = () => likesAggregate()?.ids.length ?? 0; + const comment = newSignal(''); return
@@ -272,7 +275,7 @@ export const RootComment = () => { - +
; }; diff --git a/src/thread.tsx b/src/thread.tsx index dc6733f..d3b585b 100644 --- a/src/thread.tsx +++ b/src/thread.tsx @@ -287,7 +287,7 @@ export const Thread = (props: { topNestedEvents: () => NestedNoteEvent[]; bottom {context().reply.isOpen() && - { + { const c = context(); c.thread.setCollapsed(false); c.reply.isOpen(false);