From be3425994fab94a0be6fa3ffa972c4708ae7387b Mon Sep 17 00:00:00 2001 From: cyph3rasi Date: Wed, 15 Jul 2026 01:02:40 -0700 Subject: [PATCH] Hide redundant account NSFW controls on NSFW nodes Hop-State: A_06FP9K52MYKP328EHYDE018 Hop-Proposal: R_06FP9K42QBKY7ZFP7NX001R Hop-Task: T_06FP9JMAC3NYKCMJFBPQSM0 Hop-Attempt: AT_06FP9JMAC20R8XKDE9B6M7R --- src/app/settings/content/page.tsx | 37 ++++++++++++++++++++++- src/app/settings/page.tsx | 38 ++++++++++++++---------- src/lib/nsfw/settings-visibility.test.ts | 12 ++++++++ src/lib/nsfw/settings-visibility.ts | 3 ++ 4 files changed, 74 insertions(+), 16 deletions(-) create mode 100644 src/lib/nsfw/settings-visibility.test.ts create mode 100644 src/lib/nsfw/settings-visibility.ts diff --git a/src/app/settings/content/page.tsx b/src/app/settings/content/page.tsx index 5bfa36e..d2a12d8 100644 --- a/src/app/settings/content/page.tsx +++ b/src/app/settings/content/page.tsx @@ -5,6 +5,8 @@ import Link from 'next/link'; import { ArrowLeftIcon } from '@/components/Icons'; import { Eye, EyeOff, AlertTriangle, Check } from 'lucide-react'; import { useAuth } from '@/lib/contexts/AuthContext'; +import { useRuntimeConfig } from '@/lib/contexts/ConfigContext'; +import { shouldExposeAccountNsfwSettings } from '@/lib/nsfw/settings-visibility'; interface NsfwSettings { nsfwEnabled: boolean; @@ -14,6 +16,7 @@ interface NsfwSettings { export default function ContentSettingsPage() { const { isIdentityUnlocked, signUserAction, setShowUnlockPrompt } = useAuth(); + const { config, isLoading: configLoading } = useRuntimeConfig(); const [settings, setSettings] = useState(null); const [loading, setLoading] = useState(true); const [saving, setSaving] = useState(false); @@ -162,7 +165,7 @@ export default function ContentSettingsPage() { } }; - if (loading) { + if (loading || configLoading) { return (
@@ -172,6 +175,38 @@ export default function ContentSettingsPage() { ); } + if (!shouldExposeAccountNsfwSettings(config?.isNsfw ?? false)) { + return ( +
+
+ + + +
+

Content Settings

+

+ Content visibility is managed by this node +

+
+
+ +
+
+ NSFW content is enabled on this node +
+
+ This node is designated NSFW, so NSFW viewing and account sensitivity are handled at the node level. There’s nothing to configure for this account. +
+
+
+ ); + } + return (
- -
- - Content Settings -
-
- NSFW preferences and content visibility -
- + {showContentSettings && ( + +
+ + Content Settings +
+
+ NSFW preferences and content visibility +
+ + )} { + it('hides account NSFW controls when the node is already NSFW', () => { + expect(shouldExposeAccountNsfwSettings(true)).toBe(false); + }); + + it('keeps account NSFW controls available on general-purpose nodes', () => { + expect(shouldExposeAccountNsfwSettings(false)).toBe(true); + }); +}); diff --git a/src/lib/nsfw/settings-visibility.ts b/src/lib/nsfw/settings-visibility.ts new file mode 100644 index 0000000..82443fe --- /dev/null +++ b/src/lib/nsfw/settings-visibility.ts @@ -0,0 +1,3 @@ +export function shouldExposeAccountNsfwSettings(nodeIsNsfw: boolean): boolean { + return !nodeIsNsfw; +}