feat: add nsfw toggle to post editor
This commit is contained in:
@@ -37,6 +37,7 @@ export default function PostContent({
|
||||
const [addClientTag, setAddClientTag] = useState(false)
|
||||
const [specifiedRelayUrls, setSpecifiedRelayUrls] = useState<string[] | undefined>(undefined)
|
||||
const [mentions, setMentions] = useState<string[]>([])
|
||||
const [isNsfw, setIsNsfw] = useState(false)
|
||||
const canPost = !!text && !posting && !uploadingFiles
|
||||
|
||||
const post = async (e?: React.MouseEvent) => {
|
||||
@@ -50,12 +51,14 @@ export default function PostContent({
|
||||
parentEvent && parentEvent.kind !== kinds.ShortTextNote
|
||||
? await createCommentDraftEvent(text, parentEvent, mentions, {
|
||||
addClientTag,
|
||||
protectedEvent: !!specifiedRelayUrls
|
||||
protectedEvent: !!specifiedRelayUrls,
|
||||
isNsfw
|
||||
})
|
||||
: await createShortTextNoteDraftEvent(text, mentions, {
|
||||
parentEvent,
|
||||
addClientTag,
|
||||
protectedEvent: !!specifiedRelayUrls
|
||||
protectedEvent: !!specifiedRelayUrls,
|
||||
isNsfw
|
||||
})
|
||||
await publish(draftEvent, { specifiedRelayUrls })
|
||||
postContentCache.clearPostCache({ defaultContent, parentEvent })
|
||||
@@ -159,6 +162,8 @@ export default function PostContent({
|
||||
show={showMoreOptions}
|
||||
addClientTag={addClientTag}
|
||||
setAddClientTag={setAddClientTag}
|
||||
isNsfw={isNsfw}
|
||||
setIsNsfw={setIsNsfw}
|
||||
/>
|
||||
<div className="flex gap-2 items-center justify-around sm:hidden">
|
||||
<Button
|
||||
|
||||
@@ -7,11 +7,15 @@ import { useTranslation } from 'react-i18next'
|
||||
export default function PostOptions({
|
||||
show,
|
||||
addClientTag,
|
||||
setAddClientTag
|
||||
setAddClientTag,
|
||||
isNsfw,
|
||||
setIsNsfw
|
||||
}: {
|
||||
show: boolean
|
||||
addClientTag: boolean
|
||||
setAddClientTag: Dispatch<SetStateAction<boolean>>
|
||||
isNsfw: boolean
|
||||
setIsNsfw: Dispatch<SetStateAction<boolean>>
|
||||
}) {
|
||||
const { t } = useTranslation()
|
||||
|
||||
@@ -26,14 +30,29 @@ export default function PostOptions({
|
||||
window.localStorage.setItem(StorageKey.ADD_CLIENT_TAG, checked.toString())
|
||||
}
|
||||
|
||||
const onNsfwChange = (checked: boolean) => {
|
||||
setIsNsfw(checked)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
<div className="flex items-center space-x-2">
|
||||
<Label htmlFor="add-client-tag">{t('Add client tag')}</Label>
|
||||
<Switch id="add-client-tag" checked={addClientTag} onCheckedChange={onAddClientTagChange} />
|
||||
<div className="space-y-4">
|
||||
<div className="space-y-2">
|
||||
<div className="flex items-center space-x-2">
|
||||
<Label htmlFor="add-client-tag">{t('Add client tag')}</Label>
|
||||
<Switch
|
||||
id="add-client-tag"
|
||||
checked={addClientTag}
|
||||
onCheckedChange={onAddClientTagChange}
|
||||
/>
|
||||
</div>
|
||||
<div className="text-muted-foreground text-xs">
|
||||
{t('Show others this was sent via Jumble')}
|
||||
</div>
|
||||
</div>
|
||||
<div className="text-muted-foreground text-xs">
|
||||
{t('Show others this was sent via Jumble')}
|
||||
|
||||
<div className="flex items-center space-x-2">
|
||||
<Label htmlFor="add-nsfw-tag">{t('NSFW')}</Label>
|
||||
<Switch id="add-nsfw-tag" checked={isNsfw} onCheckedChange={onNsfwChange} />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user