task(CAD-14 audit): registry init before render (select warning fixed), DELETE idempotent (404-tolerant), app->v2doc delete reconcile (no ghost elements)
This commit is contained in:
@@ -326,6 +326,18 @@ const CanvasArea: React.FC<CanvasAreaProps> = ({
|
||||
renderEngine.setOverlayElements(elements);
|
||||
renderEngine.render();
|
||||
|
||||
// CAD-14 Audit-Fix: App-Löschungen in das V2-Dokument zurueckspiegeln —
|
||||
// sonst bleiben in App geloeschte Elemente als Geister in v2Doc/Pixi
|
||||
// haengen und kamen beim naechsten onChanged zurueck.
|
||||
const activeDoc = getActiveDocument();
|
||||
if (activeDoc) {
|
||||
const appIds = new Set(elements.map((e) => e.id));
|
||||
const ghostIds = activeDoc.getAllElements().filter((e) => !appIds.has(e.id)).map((e) => e.id);
|
||||
if (ghostIds.length > 0) {
|
||||
activeDoc.deleteElements(ghostIds);
|
||||
}
|
||||
}
|
||||
|
||||
// CAD-13-fix: Bestands-Elemente (aus DB geladen) müssen in Pixi gespiegelt
|
||||
// werden — nur NEUE V2-Elemente laufen über v2Doc.onChanged in syncPixi.
|
||||
// Ohne diesen Mirror blieben Alt-Projekte leer (Legacy skippt ja jetzt).
|
||||
|
||||
@@ -2,6 +2,14 @@ import React from 'react';
|
||||
import { createRoot } from 'react-dom/client';
|
||||
import App from './App';
|
||||
import { AuthProvider } from './contexts/AuthContext';
|
||||
import { registerBuiltinPlugins, pluginRegistry } from './plugins';
|
||||
|
||||
// CAD-14 Audit-Fix: Registry VOR dem React-Render initialisieren, damit
|
||||
// der erste CanvasArea-Mount (Child-Effekte laufen vor Parent-Effekten)
|
||||
// gefuellte Tools vorfindet — sonst '[InteractionDispatcher] kein
|
||||
// aktives V2-Tool select' beim App-Start.
|
||||
registerBuiltinPlugins();
|
||||
pluginRegistry.initDefaults();
|
||||
|
||||
const container = document.getElementById('root');
|
||||
if (!container) {
|
||||
|
||||
@@ -230,7 +230,9 @@ export async function deleteElement(token: string, elementId: string): Promise<v
|
||||
method: 'DELETE',
|
||||
headers: { Authorization: `Bearer ${token}` },
|
||||
});
|
||||
if (!res.ok) throw new Error('Failed to delete element');
|
||||
// CAD-14 Audit-Fix: 404 = bereits geloescht (idempotent, Race-sicher —
|
||||
// CRDT-Sync und REST-Kanal laufen parallel, zweiter Versuch ist kein Fehler).
|
||||
if (!res.ok && res.status !== 404) throw new Error('Failed to delete element');
|
||||
}
|
||||
|
||||
// ─── Layers ─────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user