fix: privacy setting is not working
This commit is contained in:
@@ -3,7 +3,7 @@ import { Event } from "@lume/types";
|
|||||||
import { cn } from "@lume/utils";
|
import { cn } from "@lume/utils";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Note, User } from "@lume/ui";
|
import { Note, Spinner, User } from "@lume/ui";
|
||||||
import { useRouteContext } from "@tanstack/react-router";
|
import { useRouteContext } from "@tanstack/react-router";
|
||||||
|
|
||||||
export function RepostNote({
|
export function RepostNote({
|
||||||
@@ -27,51 +27,16 @@ export function RepostNote({
|
|||||||
const embed: Event = JSON.parse(event.content);
|
const embed: Event = JSON.parse(event.content);
|
||||||
return embed;
|
return embed;
|
||||||
}
|
}
|
||||||
const id = event.tags.find((el) => el[0] === "e")[1];
|
const id = event.tags.find((el) => el[0] === "e")?.[1];
|
||||||
return await ark.get_event(id);
|
if (id) return await ark.get_event(id);
|
||||||
} catch {
|
} catch (e) {
|
||||||
throw new Error("Failed to get repost event");
|
throw new Error(e);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
refetchOnWindowFocus: false,
|
refetchOnWindowFocus: false,
|
||||||
refetchOnMount: false,
|
refetchOnMount: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isLoading) {
|
|
||||||
return <div className="w-full px-3 pb-3">Loading...</div>;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isError || !repostEvent) {
|
|
||||||
return (
|
|
||||||
<Note.Root
|
|
||||||
className={cn(
|
|
||||||
"flex flex-col gap-2 border-b border-neutral-100 px-3 py-5 dark:border-neutral-900",
|
|
||||||
className,
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<User.Provider pubkey={event.pubkey}>
|
|
||||||
<User.Root className="flex h-14 gap-2 px-3">
|
|
||||||
<div className="inline-flex w-10 shrink-0 items-center justify-center">
|
|
||||||
<RepostIcon className="h-5 w-5 text-blue-500" />
|
|
||||||
</div>
|
|
||||||
<div className="inline-flex items-center gap-2">
|
|
||||||
<User.Avatar className="size-6 shrink-0 rounded object-cover" />
|
|
||||||
<div className="inline-flex items-baseline gap-1">
|
|
||||||
<User.Name className="font-medium text-neutral-900 dark:text-neutral-100" />
|
|
||||||
<span className="text-blue-500">{t("note.reposted")}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</User.Root>
|
|
||||||
</User.Provider>
|
|
||||||
<div className="mb-3 select-text px-3">
|
|
||||||
<div className="flex flex-col items-start justify-start rounded-lg bg-red-100 px-3 py-3 dark:bg-red-900">
|
|
||||||
<p className="text-red-500">Failed to get event</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Note.Root>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Note.Root
|
<Note.Root
|
||||||
className={cn(
|
className={cn(
|
||||||
@@ -93,6 +58,13 @@ export function RepostNote({
|
|||||||
</div>
|
</div>
|
||||||
</User.Root>
|
</User.Root>
|
||||||
</User.Provider>
|
</User.Provider>
|
||||||
|
{isLoading ? (
|
||||||
|
<Spinner />
|
||||||
|
) : isError ? (
|
||||||
|
<div className="w-full h-16 flex items-center px-3 border border-neutral-100 dark:border-neutral-900">
|
||||||
|
<p>Event not found</p>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
<Note.Provider event={repostEvent}>
|
<Note.Provider event={repostEvent}>
|
||||||
<div className="flex flex-col gap-2">
|
<div className="flex flex-col gap-2">
|
||||||
<Note.User />
|
<Note.User />
|
||||||
@@ -113,6 +85,7 @@ export function RepostNote({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Note.Provider>
|
</Note.Provider>
|
||||||
|
)}
|
||||||
</Note.Root>
|
</Note.Root>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,9 @@ export function NoteContent({
|
|||||||
compact?: boolean;
|
compact?: boolean;
|
||||||
className?: string;
|
className?: string;
|
||||||
}) {
|
}) {
|
||||||
const settings: Settings = useRouteContext({ strict: false });
|
const { settings }: { settings: Settings } = useRouteContext({
|
||||||
|
strict: false,
|
||||||
|
});
|
||||||
const event = useNoteContext();
|
const event = useNoteContext();
|
||||||
const content = useMemo(() => {
|
const content = useMemo(() => {
|
||||||
const text = event.content.trim();
|
const text = event.content.trim();
|
||||||
@@ -124,7 +126,7 @@ export function NoteContent({
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (compact) {
|
if (compact) {
|
||||||
parsedContent = reactStringReplace(parsedContent, /\n|\r/g, () => (
|
parsedContent = reactStringReplace(parsedContent, /[\r\n]{2,}/g, () => (
|
||||||
<div key={nanoid()} className="h-1.5" />
|
<div key={nanoid()} className="h-1.5" />
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user