fix content-warning tag

This commit is contained in:
hzrd149
2023-10-26 14:23:06 -05:00
parent c54e52bc89
commit 1b8a1d299c
3 changed files with 8 additions and 6 deletions

View File

@@ -9,11 +9,11 @@ export default function NoteContentWithWarning({ event }: { event: NostrEvent })
const expand = useExpand(); const expand = useExpand();
const settings = useAppSettings(); const settings = useAppSettings();
const contentWarning = event.tags.find((t) => t[0] === "content-warning")?.[1]; const contentWarningTag = event.tags.find((t) => t[0] === "content-warning");
const showContentWarning = settings.showContentWarning && contentWarning && !expand?.expanded; const showContentWarning = settings.showContentWarning && contentWarningTag && !expand?.expanded;
return showContentWarning ? ( return showContentWarning ? (
<SensitiveContentWarning description={contentWarning} /> <SensitiveContentWarning description={contentWarningTag?.[1]} />
) : ( ) : (
<NoteContents px="2" event={event} /> <NoteContents px="2" event={event} />
); );

View File

@@ -260,7 +260,9 @@ export default function PostModal({
</FormControl> </FormControl>
<Flex gap="2" direction="column"> <Flex gap="2" direction="column">
<Switch {...register("nsfw")}>NSFW</Switch> <Switch {...register("nsfw")}>NSFW</Switch>
{getValues().nsfw && <Input {...register("nsfwReason")} placeholder="Reason" />} {getValues().nsfw && (
<Input {...register("nsfwReason", { required: true })} placeholder="Reason" isRequired />
)}
</Flex> </Flex>
</Flex> </Flex>
<Flex direction="column" gap="2" flex={1}> <Flex direction="column" gap="2" flex={1}>

View File

@@ -1,9 +1,9 @@
import { Alert, AlertDescription, AlertIcon, AlertProps, AlertTitle, Button, Spacer, useModal } from "@chakra-ui/react"; import { Alert, AlertDescription, AlertIcon, AlertProps, AlertTitle, Button, Spacer } from "@chakra-ui/react";
import { useExpand } from "../providers/expanded"; import { useExpand } from "../providers/expanded";
import { useBreakpointValue } from "../providers/breakpoint-provider"; import { useBreakpointValue } from "../providers/breakpoint-provider";
export default function SensitiveContentWarning({ description }: { description: string } & AlertProps) { export default function SensitiveContentWarning({ description }: { description?: string } & AlertProps) {
const expand = useExpand(); const expand = useExpand();
const smallScreen = useBreakpointValue({ base: true, md: false }); const smallScreen = useBreakpointValue({ base: true, md: false });