diff --git a/src/components/PageEditor.svelte b/src/components/PageEditor.svelte index 033128b..501c1d8 100644 --- a/src/components/PageEditor.svelte +++ b/src/components/PageEditor.svelte @@ -85,7 +85,16 @@ credentials: 'include', body: JSON.stringify({ content, base_hash: baseHash }), }); - if (r.status === 409) { errorMsg = await r.text(); return; } + if (r.status === 409) { + const data = await r.json(); + const detail = data.detail ?? {}; + errorMsg = typeof detail === 'string' ? detail : (detail.message ?? 'Conflitto'); + if (detail.content) { + content = detail.content; + baseHash = detail.base_hash ?? baseHash; + } + return; + } if (!r.ok) throw new Error(await r.text()); saveStatus = 'Costruendo…'; const rb = await fetch('/rebuild', { method: 'POST', credentials: 'include' });