Handle 3-way merge conflict in editor: show markers, update base_hash

This commit is contained in:
Davide Scaini
2026-05-08 08:47:42 +02:00
parent 1539bdb3a7
commit 476f605a4a
+10 -1
View File
@@ -85,7 +85,16 @@
credentials: 'include', credentials: 'include',
body: JSON.stringify({ content, base_hash: baseHash }), 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()); if (!r.ok) throw new Error(await r.text());
saveStatus = 'Costruendo…'; saveStatus = 'Costruendo…';
const rb = await fetch('/rebuild', { method: 'POST', credentials: 'include' }); const rb = await fetch('/rebuild', { method: 'POST', credentials: 'include' });