From f3c52237fa6fdd5a137250144894995306b3df98 Mon Sep 17 00:00:00 2001 From: reya Date: Wed, 17 Apr 2024 13:50:50 +0700 Subject: [PATCH] fix: privacy setting is not working --- apps/desktop2/src/components/repost.tsx | 85 +++++++++---------------- packages/ui/src/note/content.tsx | 6 +- 2 files changed, 33 insertions(+), 58 deletions(-) diff --git a/apps/desktop2/src/components/repost.tsx b/apps/desktop2/src/components/repost.tsx index 5ee96d5a..a6bd28ca 100644 --- a/apps/desktop2/src/components/repost.tsx +++ b/apps/desktop2/src/components/repost.tsx @@ -3,7 +3,7 @@ import { Event } from "@lume/types"; import { cn } from "@lume/utils"; import { useQuery } from "@tanstack/react-query"; import { useTranslation } from "react-i18next"; -import { Note, User } from "@lume/ui"; +import { Note, Spinner, User } from "@lume/ui"; import { useRouteContext } from "@tanstack/react-router"; export function RepostNote({ @@ -27,51 +27,16 @@ export function RepostNote({ const embed: Event = JSON.parse(event.content); return embed; } - const id = event.tags.find((el) => el[0] === "e")[1]; - return await ark.get_event(id); - } catch { - throw new Error("Failed to get repost event"); + const id = event.tags.find((el) => el[0] === "e")?.[1]; + if (id) return await ark.get_event(id); + } catch (e) { + throw new Error(e); } }, refetchOnWindowFocus: false, refetchOnMount: false, }); - if (isLoading) { - return
Loading...
; - } - - if (isError || !repostEvent) { - return ( - - - -
- -
-
- -
- - {t("note.reposted")} -
-
-
-
-
-
-

Failed to get event

-
-
-
- ); - } - return ( - -
- -
-
-
- -
-
- - - - {settings.zap ? : null} + {isLoading ? ( + + ) : isError ? ( +
+

Event not found

+
+ ) : ( + +
+ +
+
+
+ +
+
+ + + + {settings.zap ? : null} +
+
-
-
-
+ + )} ); } diff --git a/packages/ui/src/note/content.tsx b/packages/ui/src/note/content.tsx index 9d3f50d4..ae08c8f7 100644 --- a/packages/ui/src/note/content.tsx +++ b/packages/ui/src/note/content.tsx @@ -25,7 +25,9 @@ export function NoteContent({ compact?: boolean; className?: string; }) { - const settings: Settings = useRouteContext({ strict: false }); + const { settings }: { settings: Settings } = useRouteContext({ + strict: false, + }); const event = useNoteContext(); const content = useMemo(() => { const text = event.content.trim(); @@ -124,7 +126,7 @@ export function NoteContent({ ); if (compact) { - parsedContent = reactStringReplace(parsedContent, /\n|\r/g, () => ( + parsedContent = reactStringReplace(parsedContent, /[\r\n]{2,}/g, () => (
)); }