Hide redundant account NSFW controls on NSFW nodes
Hop-State: A_06FP9K52MYKP328EHYDE018 Hop-Proposal: R_06FP9K42QBKY7ZFP7NX001R Hop-Task: T_06FP9JMAC3NYKCMJFBPQSM0 Hop-Attempt: AT_06FP9JMAC20R8XKDE9B6M7R
This commit is contained in:
@@ -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<NsfwSettings | null>(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 (
|
||||
<div style={{ maxWidth: '600px', margin: '0 auto', padding: '24px 16px 64px' }}>
|
||||
<div style={{ textAlign: 'center', padding: '48px', color: 'var(--foreground-tertiary)' }}>
|
||||
@@ -172,6 +175,38 @@ export default function ContentSettingsPage() {
|
||||
);
|
||||
}
|
||||
|
||||
if (!shouldExposeAccountNsfwSettings(config?.isNsfw ?? false)) {
|
||||
return (
|
||||
<div style={{ maxWidth: '600px', margin: '0 auto', padding: '24px 16px 64px' }}>
|
||||
<header style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
gap: '16px',
|
||||
marginBottom: '32px',
|
||||
}}>
|
||||
<Link href="/settings" style={{ color: 'var(--foreground)' }}>
|
||||
<ArrowLeftIcon />
|
||||
</Link>
|
||||
<div>
|
||||
<h1 style={{ fontSize: '24px', fontWeight: 700 }}>Content Settings</h1>
|
||||
<p style={{ color: 'var(--foreground-tertiary)', fontSize: '14px' }}>
|
||||
Content visibility is managed by this node
|
||||
</p>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div className="card" style={{ padding: '20px' }}>
|
||||
<div style={{ fontWeight: 600, marginBottom: '8px' }}>
|
||||
NSFW content is enabled on this node
|
||||
</div>
|
||||
<div style={{ color: 'var(--foreground-secondary)', fontSize: '14px', lineHeight: 1.6 }}>
|
||||
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.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div style={{ maxWidth: '600px', margin: '0 auto', padding: '24px 16px 64px' }}>
|
||||
<header style={{
|
||||
|
||||
@@ -3,8 +3,14 @@
|
||||
import Link from 'next/link';
|
||||
|
||||
import { Rocket, Shield, Bell, Eye, UserX, HardDrive } from 'lucide-react';
|
||||
import { useRuntimeConfig } from '@/lib/contexts/ConfigContext';
|
||||
import { shouldExposeAccountNsfwSettings } from '@/lib/nsfw/settings-visibility';
|
||||
|
||||
export default function SettingsPage() {
|
||||
const { config, isLoading: configLoading } = useRuntimeConfig();
|
||||
const showContentSettings = !configLoading
|
||||
&& shouldExposeAccountNsfwSettings(config?.isNsfw ?? false);
|
||||
|
||||
return (
|
||||
<>
|
||||
<header style={{
|
||||
@@ -43,6 +49,7 @@ export default function SettingsPage() {
|
||||
</Link>
|
||||
|
||||
|
||||
{showContentSettings && (
|
||||
<Link href="/settings/content" className="card" style={{
|
||||
display: 'block',
|
||||
padding: '20px',
|
||||
@@ -58,6 +65,7 @@ export default function SettingsPage() {
|
||||
NSFW preferences and content visibility
|
||||
</div>
|
||||
</Link>
|
||||
)}
|
||||
|
||||
<Link href="/settings/privacy" className="card" style={{
|
||||
display: 'block',
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { shouldExposeAccountNsfwSettings } from './settings-visibility';
|
||||
|
||||
describe('shouldExposeAccountNsfwSettings', () => {
|
||||
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);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,3 @@
|
||||
export function shouldExposeAccountNsfwSettings(nodeIsNsfw: boolean): boolean {
|
||||
return !nodeIsNsfw;
|
||||
}
|
||||
Reference in New Issue
Block a user