fix: preserve connector persistence without breaking image export

The deep comparison logic from commit 2733f0b prevented the export dialog's
Isoflow instance from properly initializing. Now bypasses the comparison
check when in NON_INTERACTIVE mode (used for export).

Testing process:
- Bisected commits to identify 2733f0b as the breaking change
- Tested working commit 8db2710 vs broken commit 2733f0b
- Confirmed deep comparison was preventing initialization
- Implemented conditional check based on editor mode
- Verified export now works while connector persistence is maintained

Fixed it and will in future not be a massive idiot and will properly test things -stan
This commit is contained in:
Stan
2025-08-27 18:28:31 +01:00
parent 20e4579648
commit 650045d958
2 changed files with 14 additions and 3 deletions

View File

@@ -105,8 +105,15 @@ export const ExportImageDialog = ({ onClose, quality = 1.5 }: Props) => {
}, 100);
return () => clearTimeout(timer);
}, [showGrid, backgroundColor]);
}, [showGrid, backgroundColor, exportImage]);
useEffect(() => {
const timer = setTimeout(() => {
exportImage();
}, 100);
return () => clearTimeout(timer);
}, []);
const downloadFile = useCallback(() => {
if (!imageData) return;

View File

@@ -26,6 +26,9 @@ export const useInitialDataManager = () => {
const rendererEl = useUiStateStore((state) => {
return state.rendererEl;
});
const editorMode = useUiStateStore((state) => {
return state.editorMode;
});
const { changeView } = useView();
const load = useCallback(
@@ -33,7 +36,8 @@ export const useInitialDataManager = () => {
if (!_initialData || prevInitialData.current === _initialData) return;
// Deep comparison to prevent unnecessary reloads when data hasn't actually changed
if (prevInitialData.current) {
// Skip this check for NON_INTERACTIVE mode (used by export) to ensure proper initialization
if (prevInitialData.current && editorMode !== 'NON_INTERACTIVE') {
const prevConnectors = JSON.stringify(prevInitialData.current.views?.[0]?.connectors || []);
const newConnectors = JSON.stringify(_initialData.views?.[0]?.connectors || []);
const prevItems = JSON.stringify(prevInitialData.current.items || []);
@@ -111,7 +115,7 @@ export const useInitialDataManager = () => {
setIsReady(true);
},
[changeView, model.actions, rendererEl, uiStateActions]
[changeView, model.actions, rendererEl, uiStateActions, editorMode]
);
const clear = useCallback(() => {