[121] Neurendern Teil 3: App abonniert das Projekt nicht mehr – Griffe, Zifferntasten und Befehlszeile in views/ViewportCenter, Kontextmenü/Dialoge/ProjectSync lesen selbst, Handler über getState(), Panel-Host baut lazy; schmale Selektoren in App-Hooks und einigen Panels; Wand-Änderung 42 → 40 Renders, App 0× (e2e prüft es); Doku und TODO nachgeführt
This commit is contained in:
41 files changed
+886
-551
No files matched your search
@@ -63,7 +63,7 @@ export async function openLayerSettingsWindowNative(code: string): Promise<void>
|
||||
}
|
||||
|
||||
/** Baut den Sync-Zustand für eine Kategorie (bzw. `null`, wenn der Code nicht mehr existiert — z. B. gelöscht). */
|
||||
function stateFor(project: Project, code: string): LayerSettingsSyncState | null {
|
||||
function stateFor(project: Pick<Project, "layers" | "hatches">, code: string): LayerSettingsSyncState | null {
|
||||
const cat = findCategory(project.layers, code);
|
||||
if (!cat) return null;
|
||||
return {
|
||||
@@ -78,10 +78,10 @@ function stateFor(project: Project, code: string): LayerSettingsSyncState | null
|
||||
|
||||
/** Hauptfenster-Seite der Sync-Brücke. `code` = aktuell im Fenster editierte Ebene (folgt `openLayerSettingsWindowNative`-Aufrufen). */
|
||||
export function useLayerSettingsWindowHost(
|
||||
project: Project,
|
||||
project: Pick<Project, "layers" | "hatches">,
|
||||
code: string | null,
|
||||
onPatchCategory: (code: string, patch: Partial<LayerCategory>) => void,
|
||||
): void {
|
||||
const state: LayerSettingsSyncState | null = code ? stateFor(project, code) : null;
|
||||
useWindowBridgeHost(LAYER_SETTINGS_WINDOW_LABEL, "layer-settings", state, { onPatchCategory: (c: string, patch: Partial<LayerCategory>) => onPatchCategory(c, patch) }, [project, code]);
|
||||
useWindowBridgeHost(LAYER_SETTINGS_WINDOW_LABEL, "layer-settings", state, { onPatchCategory: (c: string, patch: Partial<LayerCategory>) => onPatchCategory(c, patch) }, [project.layers, project.hatches, code]);
|
||||
}
|
||||
@@ -68,7 +68,8 @@ export async function openResourceWindowNative(initialTab?: TabId): Promise<void
|
||||
* `resourceHandlers`).
|
||||
*/
|
||||
export function useResourceWindowHost(
|
||||
project: Project,
|
||||
/** Aktuelles Projekt; `null` ausserhalb von Tauri (dann abonniert der Aufrufer es nicht, [121]). */
|
||||
project: Project | null,
|
||||
handlers: ResourceManagerHandlers,
|
||||
): void {
|
||||
const handlersRef = useRef(handlers);
|
||||
@@ -102,6 +103,7 @@ export function useResourceWindowHost(
|
||||
unlisten.push(
|
||||
await listen("resource-window-ready", () => {
|
||||
const full = projectRef.current;
|
||||
if (!full) return;
|
||||
sentRef.current = full;
|
||||
void emitTo(RESOURCE_WINDOW_LABEL, "resource-sync-project", full).catch(() => {
|
||||
sentRef.current = null;
|
||||
@@ -123,7 +125,7 @@ export function useResourceWindowHost(
|
||||
// gar nicht da ist. Kurz gebündelt, damit schnelle Folgeänderungen (Ziehen)
|
||||
// nicht jedes Mal das ganze Projekt serialisieren.
|
||||
useEffect(() => {
|
||||
if (!isTauriRuntime()) return;
|
||||
if (!isTauriRuntime() || !project) return;
|
||||
let cancelled = false;
|
||||
const timer = setTimeout(() => {
|
||||
void (async () => {
|
||||
|
||||
Reference in new issue
Block a user