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 { ArrowLeftIcon } from '@/components/Icons';
|
||||||
import { Eye, EyeOff, AlertTriangle, Check } from 'lucide-react';
|
import { Eye, EyeOff, AlertTriangle, Check } from 'lucide-react';
|
||||||
import { useAuth } from '@/lib/contexts/AuthContext';
|
import { useAuth } from '@/lib/contexts/AuthContext';
|
||||||
|
import { useRuntimeConfig } from '@/lib/contexts/ConfigContext';
|
||||||
|
import { shouldExposeAccountNsfwSettings } from '@/lib/nsfw/settings-visibility';
|
||||||
|
|
||||||
interface NsfwSettings {
|
interface NsfwSettings {
|
||||||
nsfwEnabled: boolean;
|
nsfwEnabled: boolean;
|
||||||
@@ -14,6 +16,7 @@ interface NsfwSettings {
|
|||||||
|
|
||||||
export default function ContentSettingsPage() {
|
export default function ContentSettingsPage() {
|
||||||
const { isIdentityUnlocked, signUserAction, setShowUnlockPrompt } = useAuth();
|
const { isIdentityUnlocked, signUserAction, setShowUnlockPrompt } = useAuth();
|
||||||
|
const { config, isLoading: configLoading } = useRuntimeConfig();
|
||||||
const [settings, setSettings] = useState<NsfwSettings | null>(null);
|
const [settings, setSettings] = useState<NsfwSettings | null>(null);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [saving, setSaving] = useState(false);
|
const [saving, setSaving] = useState(false);
|
||||||
@@ -162,7 +165,7 @@ export default function ContentSettingsPage() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (loading) {
|
if (loading || configLoading) {
|
||||||
return (
|
return (
|
||||||
<div style={{ maxWidth: '600px', margin: '0 auto', padding: '24px 16px 64px' }}>
|
<div style={{ maxWidth: '600px', margin: '0 auto', padding: '24px 16px 64px' }}>
|
||||||
<div style={{ textAlign: 'center', padding: '48px', color: 'var(--foreground-tertiary)' }}>
|
<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 (
|
return (
|
||||||
<div style={{ maxWidth: '600px', margin: '0 auto', padding: '24px 16px 64px' }}>
|
<div style={{ maxWidth: '600px', margin: '0 auto', padding: '24px 16px 64px' }}>
|
||||||
<header style={{
|
<header style={{
|
||||||
|
|||||||
+23
-15
@@ -3,8 +3,14 @@
|
|||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
|
|
||||||
import { Rocket, Shield, Bell, Eye, UserX, HardDrive } from 'lucide-react';
|
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() {
|
export default function SettingsPage() {
|
||||||
|
const { config, isLoading: configLoading } = useRuntimeConfig();
|
||||||
|
const showContentSettings = !configLoading
|
||||||
|
&& shouldExposeAccountNsfwSettings(config?.isNsfw ?? false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<header style={{
|
<header style={{
|
||||||
@@ -43,21 +49,23 @@ export default function SettingsPage() {
|
|||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
|
|
||||||
<Link href="/settings/content" className="card" style={{
|
{showContentSettings && (
|
||||||
display: 'block',
|
<Link href="/settings/content" className="card" style={{
|
||||||
padding: '20px',
|
display: 'block',
|
||||||
textDecoration: 'none',
|
padding: '20px',
|
||||||
color: 'var(--foreground)',
|
textDecoration: 'none',
|
||||||
transition: 'border-color 0.15s ease',
|
color: 'var(--foreground)',
|
||||||
}}>
|
transition: 'border-color 0.15s ease',
|
||||||
<div style={{ fontWeight: 600, marginBottom: '8px', display: 'flex', alignItems: 'center', gap: '8px' }}>
|
}}>
|
||||||
<Eye size={18} />
|
<div style={{ fontWeight: 600, marginBottom: '8px', display: 'flex', alignItems: 'center', gap: '8px' }}>
|
||||||
Content Settings
|
<Eye size={18} />
|
||||||
</div>
|
Content Settings
|
||||||
<div style={{ color: 'var(--foreground-secondary)', fontSize: '14px' }}>
|
</div>
|
||||||
NSFW preferences and content visibility
|
<div style={{ color: 'var(--foreground-secondary)', fontSize: '14px' }}>
|
||||||
</div>
|
NSFW preferences and content visibility
|
||||||
</Link>
|
</div>
|
||||||
|
</Link>
|
||||||
|
)}
|
||||||
|
|
||||||
<Link href="/settings/privacy" className="card" style={{
|
<Link href="/settings/privacy" className="card" style={{
|
||||||
display: 'block',
|
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