fix: some issues with publish new note
This commit is contained in:
@@ -400,9 +400,9 @@ async publish(content: string, warning: string | null, difficulty: number | null
|
||||
else return { status: "error", error: e as any };
|
||||
}
|
||||
},
|
||||
async reply(content: string, to: string, root: string | null) : Promise<Result<string, string>> {
|
||||
async reply(content: string, to: string) : Promise<Result<string, string>> {
|
||||
try {
|
||||
return { status: "ok", data: await TAURI_INVOKE("reply", { content, to, root }) };
|
||||
return { status: "ok", data: await TAURI_INVOKE("reply", { content, to }) };
|
||||
} catch (e) {
|
||||
if(e instanceof Error) throw e;
|
||||
else return { status: "error", error: e as any };
|
||||
|
||||
@@ -12,7 +12,14 @@ export function NoteOpenThread() {
|
||||
<Tooltip.Trigger asChild>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => LumeWindow.openEvent(event)}
|
||||
onClick={() =>
|
||||
LumeWindow.openColumn({
|
||||
name: "Thread",
|
||||
label: event.id.slice(0, 6),
|
||||
account: event.pubkey,
|
||||
url: `/columns/events/${event.id}`,
|
||||
})
|
||||
}
|
||||
className="group inline-flex h-7 w-14 bg-neutral-100 dark:bg-white/10 rounded-full items-center justify-center text-sm font-medium text-neutral-800 dark:text-neutral-200 hover:text-blue-500 hover:bg-neutral-200 dark:hover:bg-white/20"
|
||||
>
|
||||
<ListPlus className="shrink-0 size-4" />
|
||||
|
||||
@@ -56,7 +56,14 @@ export const MentionNote = memo(function MentionNote({
|
||||
<div className="invisible group-hover:visible flex items-center justify-end">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => LumeWindow.openEvent(event)}
|
||||
onClick={() =>
|
||||
LumeWindow.openColumn({
|
||||
name: "Thread",
|
||||
label: eventId.slice(0, 6),
|
||||
account: event.pubkey,
|
||||
url: `/columns/events/${eventId}`,
|
||||
})
|
||||
}
|
||||
className="mr-3 text-sm font-medium text-blue-500 hover:text-blue-600"
|
||||
>
|
||||
Show all
|
||||
|
||||
@@ -14,8 +14,6 @@ export const RepostNote = memo(function RepostNote({
|
||||
}) {
|
||||
const { isLoading, isError, data } = useEvent(event.repostId, event.content);
|
||||
|
||||
console.log("Repost: ", event);
|
||||
|
||||
return (
|
||||
<Note.Root className={cn("", className)}>
|
||||
{isLoading ? (
|
||||
|
||||
@@ -33,7 +33,7 @@ function Screen() {
|
||||
>
|
||||
<ScrollArea.Viewport
|
||||
ref={ref}
|
||||
className="relative h-full bg-white dark:bg-neutral-800 rounded-t-xl shadow shadow-neutral-300/50 dark:shadow-none border-[.5px] border-neutral-300 dark:border-neutral-700"
|
||||
className="pb-3 relative h-full bg-white dark:bg-neutral-800 rounded-t-xl shadow shadow-neutral-300/50 dark:shadow-none border-[.5px] border-neutral-300 dark:border-neutral-700"
|
||||
>
|
||||
<Virtualizer scrollRef={ref as unknown as RefObject<HTMLElement>}>
|
||||
<RootEvent />
|
||||
@@ -57,16 +57,16 @@ function RootEvent() {
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div className="flex items-center gap-2 text-sm">
|
||||
<Spinner />
|
||||
Loading...
|
||||
<div className="h-20 flex items-center justify-center gap-2 border-b-[.5px] border-neutral-300 dark:border-neutral-700">
|
||||
<Spinner className="size-4" />
|
||||
<p className="text-sm">Loading...</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (isError || !event) {
|
||||
return (
|
||||
<div className="flex items-center gap-2 text-sm text-red-500">
|
||||
<div className="flex items-center gap-2 text-sm text-red-500 border-b-[.5px] border-neutral-300 dark:border-neutral-700">
|
||||
{error?.message || "Event not found within your current relay set"}
|
||||
</div>
|
||||
);
|
||||
@@ -80,7 +80,7 @@ function RootEvent() {
|
||||
<Note.Menu />
|
||||
</div>
|
||||
<Note.ContentLarge className="px-3" />
|
||||
<div className="flex items-center gap-2 px-3 mt-6 h-12 rounded-b-xl bg-neutral-50 dark:bg-white/5">
|
||||
<div className="select-text flex items-center gap-2 px-3 mt-6 h-12 bg-neutral-50 dark:bg-white/5">
|
||||
<Note.Reply label />
|
||||
<Note.Repost label />
|
||||
<Note.Zap label />
|
||||
@@ -94,7 +94,7 @@ function ReplyList() {
|
||||
const { id } = Route.useParams();
|
||||
const { queryClient } = Route.useRouteContext();
|
||||
const { data, isLoading } = useQuery({
|
||||
queryKey: ["reply", id],
|
||||
queryKey: ["replies", id],
|
||||
queryFn: async () => {
|
||||
const res = await commands.getReplies(id);
|
||||
|
||||
@@ -183,8 +183,10 @@ function ReplyList() {
|
||||
"event",
|
||||
async (data) => {
|
||||
const event = LumeEvent.from(data.payload.raw, data.payload.parsed);
|
||||
console.log(event);
|
||||
|
||||
await queryClient.setQueryData(
|
||||
["reply", id],
|
||||
["replies", id],
|
||||
(prevEvents: LumeEvent[]) => {
|
||||
if (!prevEvents) return [event];
|
||||
return [event, ...prevEvents];
|
||||
@@ -204,11 +206,9 @@ function ReplyList() {
|
||||
All replies
|
||||
</div>
|
||||
{isLoading ? (
|
||||
<div className="flex items-center justify-center w-full mb-3 h-12 bg-black/5 dark:bg-white/5 rounded-xl">
|
||||
<div className="flex items-center justify-center gap-2">
|
||||
<Spinner className="size-4" />
|
||||
<span className="text-sm font-medium">Getting replies...</span>
|
||||
</div>
|
||||
<div className="flex items-center justify-center gap-2">
|
||||
<Spinner className="size-4" />
|
||||
<span className="text-sm font-medium">Getting replies...</span>
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex flex-col gap-3">
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { type Mention, type Result, commands } from "@/commands.gen";
|
||||
import { type Mention, commands } from "@/commands.gen";
|
||||
import { cn, displayNpub } from "@/commons";
|
||||
import { PublishIcon, Spinner } from "@/components";
|
||||
import { Note } from "@/components/note";
|
||||
import { User } from "@/components/user";
|
||||
import { useEvent } from "@/system";
|
||||
import { LumeWindow, useEvent } from "@/system";
|
||||
import type { Metadata } from "@/types";
|
||||
import { CaretDown } from "@phosphor-icons/react";
|
||||
import { createLazyFileRoute, useAwaited } from "@tanstack/react-router";
|
||||
@@ -69,7 +69,7 @@ export const Route = createLazyFileRoute("/new-post/")({
|
||||
|
||||
function Screen() {
|
||||
const { reply_to } = Route.useSearch();
|
||||
const { accounts, initialValue } = Route.useRouteContext();
|
||||
const { accounts, initialValue, queryClient } = Route.useRouteContext();
|
||||
const { deferMentionList } = Route.useLoaderData();
|
||||
const users = useAwaited({ promise: deferMentionList })[0];
|
||||
|
||||
@@ -163,19 +163,35 @@ function Screen() {
|
||||
const warn = warning.enable ? warning.reason : null;
|
||||
const diff = difficulty.enable ? difficulty.num : null;
|
||||
|
||||
let res: Result<string, string>;
|
||||
|
||||
if (reply_to?.length) {
|
||||
res = await commands.reply(content, reply_to, null);
|
||||
} else {
|
||||
res = await commands.publish(content, warn, diff);
|
||||
}
|
||||
const res = await commands.reply(content, reply_to);
|
||||
|
||||
if (res.status === "ok") {
|
||||
setText("");
|
||||
setIsPublish(true);
|
||||
if (res.status === "ok") {
|
||||
setText("");
|
||||
setIsPublish(true);
|
||||
|
||||
await queryClient.invalidateQueries({
|
||||
queryKey: ["replies", reply_to],
|
||||
});
|
||||
} else {
|
||||
setError(res.error);
|
||||
}
|
||||
} else {
|
||||
setError(res.error);
|
||||
const res = await commands.publish(content, warn, diff);
|
||||
|
||||
if (res.status === "ok") {
|
||||
setText("");
|
||||
setIsPublish(true);
|
||||
|
||||
await LumeWindow.openColumn({
|
||||
name: "Thread",
|
||||
label: res.data.slice(0, 6),
|
||||
account: currentUser,
|
||||
url: `/columns/events/${res.data}`,
|
||||
});
|
||||
} else {
|
||||
setError(res.error);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -207,15 +223,16 @@ function Screen() {
|
||||
<div className="flex flex-col w-full h-full">
|
||||
<div data-tauri-drag-region className="h-11 shrink-0" />
|
||||
<div className="flex flex-col flex-1 overflow-y-auto">
|
||||
{error?.length ? (
|
||||
<div className="flex flex-col gap-2 px-3.5 py-3 border-b border-black/5 dark:border-white/5">
|
||||
<p className="text-sm font-medium text-red-600">Error: {error}</p>
|
||||
</div>
|
||||
) : null}
|
||||
{reply_to?.length ? (
|
||||
<div className="flex flex-col gap-2 px-3.5 pb-3 border-b border-black/5 dark:border-white/5">
|
||||
<div className="flex flex-col gap-2 px-3.5 py-3 border-b border-black/5 dark:border-white/5">
|
||||
<span className="text-sm font-semibold">Reply to:</span>
|
||||
<EmbedNote id={reply_to} />
|
||||
</div>
|
||||
) : error?.length ? (
|
||||
<div className="flex flex-col gap-2 px-3.5 pb-3 border-b border-black/5 dark:border-white/5">
|
||||
<p className="text-sm font-medium text-red-600">{error}</p>
|
||||
</div>
|
||||
) : null}
|
||||
<div className="p-4 overflow-y-auto h-full">
|
||||
<RichTextarea
|
||||
|
||||
Reference in New Issue
Block a user