Skip to content

Commit

Permalink
Improve workaround for franzaps#50
Browse files Browse the repository at this point in the history
  • Loading branch information
alopatindev committed Jul 16, 2024
1 parent 64560d1 commit 79b8c26
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/reply.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>; replyTo?: string; onDone?: Function; }) => {
const comment = () => props.comment();
const setComment = (text: string) => props.comment(text);
const [loading, setLoading] = createSignal(false);
const [loggedInUser, setLoggedInUser] = createSignal<Profile>();
const [errorMessage, setErrorMessage] = createSignal('');
Expand Down Expand Up @@ -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 <div class="ztr-comment-new">
<div class="ztr-comment-body">
Expand All @@ -272,7 +275,7 @@ export const RootComment = () => {
</li>
</Show>
</ul>
<ReplyEditor />
<ReplyEditor comment={comment} />
</div>
</div>;
};
2 changes: 1 addition & 1 deletion src/thread.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ export const Thread = (props: { topNestedEvents: () => NestedNoteEvent[]; bottom
</Show>
</ul>
{context().reply.isOpen() &&
<ReplyEditor replyTo={event().id} onDone={() => {
<ReplyEditor comment={context().reply.text} replyTo={event().id} onDone={() => {
const c = context();
c.thread.setCollapsed(false);
c.reply.isOpen(false);
Expand Down

0 comments on commit 79b8c26

Please sign in to comment.