From 59eaaec9033b5b0524fd4208688606e35393abf6 Mon Sep 17 00:00:00 2001 From: reya <123083837+reyamir@users.noreply.github.com> Date: Fri, 21 Jun 2024 08:57:49 +0700 Subject: [PATCH] feat: support content warning --- apps/desktop2/src/components/note/content.tsx | 41 +++++++++++++++---- packages/system/src/event.ts | 25 ++++++++--- 2 files changed, 54 insertions(+), 12 deletions(-) diff --git a/apps/desktop2/src/components/note/content.tsx b/apps/desktop2/src/components/note/content.tsx index e0095ee0..f2d647b4 100644 --- a/apps/desktop2/src/components/note/content.tsx +++ b/apps/desktop2/src/components/note/content.tsx @@ -1,7 +1,7 @@ import { cn } from "@lume/utils"; import { useRouteContext } from "@tanstack/react-router"; import { nanoid } from "nanoid"; -import { type ReactNode, useMemo } from "react"; +import { type ReactNode, useMemo, useState } from "react"; import reactStringReplace from "react-string-replace"; import { Hashtag } from "./mentions/hashtag"; import { MentionNote } from "./mentions/note"; @@ -23,6 +23,8 @@ export function NoteContent({ }) { const { settings } = useRouteContext({ strict: false }); const event = useNoteContext(); + + const warning = useMemo(() => event.warning, [event]); const content = useMemo(() => { try { // Get parsed meta @@ -91,8 +93,29 @@ export function NoteContent({ } }, [event.content]); + const [blurred, setBlurred] = useState(() => warning?.length > 0); + return ( -
+ The content is hidden because the author
+
+ marked it with a warning for a reason:
+
{warning}
+ +