feat: enhance admin settings handling and update RightSidebar to use dynamic node description

This commit is contained in:
Christopher
2026-01-22 05:08:15 -08:00
parent 52883ba380
commit bb1d31c1e7
2 changed files with 20 additions and 10 deletions
+8 -5
View File
@@ -163,13 +163,14 @@ export default function AdminPage() {
} }
}; };
const handleSaveSettings = async () => { const handleSaveSettings = async (override?: typeof nodeSettings) => {
const payload = override ?? nodeSettings;
setSavingSettings(true); setSavingSettings(true);
try { try {
const res = await fetch('/api/admin/node', { const res = await fetch('/api/admin/node', {
method: 'PATCH', method: 'PATCH',
headers: { 'Content-Type': 'application/json' }, headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(nodeSettings), body: JSON.stringify(payload),
}); });
if (res.ok) { if (res.ok) {
alert('Settings saved!'); alert('Settings saved!');
@@ -204,10 +205,12 @@ export default function AdminPage() {
throw new Error(data.error || 'Upload failed'); throw new Error(data.error || 'Upload failed');
} }
setNodeSettings((prev) => ({ const nextSettings = {
...prev, ...nodeSettings,
bannerUrl: data.media?.url || data.url, bannerUrl: data.media?.url || data.url,
})); };
setNodeSettings(nextSettings);
await handleSaveSettings(nextSettings);
} catch (error) { } catch (error) {
console.error('Banner upload failed', error); console.error('Banner upload failed', error);
setBannerUploadError('Upload failed. Please try again.'); setBannerUploadError('Upload failed. Please try again.');
+12 -5
View File
@@ -3,21 +3,28 @@
import { useState, useEffect } from 'react'; import { useState, useEffect } from 'react';
export function RightSidebar() { export function RightSidebar() {
const fallbackDescription = process.env.NEXT_PUBLIC_NODE_DESCRIPTION || 'A federated social network node.';
const [nodeInfo, setNodeInfo] = useState({ const [nodeInfo, setNodeInfo] = useState({
name: process.env.NEXT_PUBLIC_NODE_NAME || 'Synapsis Node', name: process.env.NEXT_PUBLIC_NODE_NAME || 'Synapsis Node',
description: 'A federated social network designed as global communication infrastructure. Signal over noise. Identity that is truly yours.', description: fallbackDescription,
longDescription: '', longDescription: '',
rules: '', rules: '',
bannerUrl: '', bannerUrl: '',
}); });
useEffect(() => { useEffect(() => {
fetch('/api/node') fetch('/api/node', { cache: 'no-store' })
.then(res => res.json()) .then(res => res.json())
.then(data => { .then(data => {
if (data.name) { setNodeInfo(prev => ({
setNodeInfo(prev => ({ ...prev, ...data })); ...prev,
} ...data,
name: data?.name ?? prev.name,
description: data?.description ?? prev.description,
longDescription: data?.longDescription ?? prev.longDescription,
rules: data?.rules ?? prev.rules,
bannerUrl: data?.bannerUrl ?? prev.bannerUrl,
}));
}) })
.catch(() => { }); .catch(() => { });
}, []); }, []);