|
|
@ -16,7 +16,7 @@ import {
|
|
|
|
UIChildrenComponents,
|
|
|
|
UIChildrenComponents,
|
|
|
|
UIWelcomeScreenComponents,
|
|
|
|
UIWelcomeScreenComponents,
|
|
|
|
} from "../types";
|
|
|
|
} from "../types";
|
|
|
|
import { isShallowEqual, muteFSAbortError, getReactChildren } from "../utils";
|
|
|
|
import { muteFSAbortError, getReactChildren } from "../utils";
|
|
|
|
import { SelectedShapeActions, ShapesSwitcher } from "./Actions";
|
|
|
|
import { SelectedShapeActions, ShapesSwitcher } from "./Actions";
|
|
|
|
import { ErrorDialog } from "./ErrorDialog";
|
|
|
|
import { ErrorDialog } from "./ErrorDialog";
|
|
|
|
import { ExportCB, ImageExportDialog } from "./ImageExportDialog";
|
|
|
|
import { ExportCB, ImageExportDialog } from "./ImageExportDialog";
|
|
|
@ -480,39 +480,28 @@ const LayerUI = ({
|
|
|
|
);
|
|
|
|
);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const stripIrrelevantAppStateProps = (
|
|
|
|
const areEqual = (prev: LayerUIProps, next: LayerUIProps) => {
|
|
|
|
appState: AppState,
|
|
|
|
const getNecessaryObj = (appState: AppState): Partial<AppState> => {
|
|
|
|
): Partial<AppState> => {
|
|
|
|
const {
|
|
|
|
const { suggestedBindings, startBoundElement, cursorButton, ...ret } =
|
|
|
|
suggestedBindings,
|
|
|
|
appState;
|
|
|
|
startBoundElement: boundElement,
|
|
|
|
return ret;
|
|
|
|
...ret
|
|
|
|
};
|
|
|
|
} = appState;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
const areEqual = (prevProps: LayerUIProps, nextProps: LayerUIProps) => {
|
|
|
|
};
|
|
|
|
// short-circuit early
|
|
|
|
const prevAppState = getNecessaryObj(prev.appState);
|
|
|
|
if (prevProps.children !== nextProps.children) {
|
|
|
|
const nextAppState = getNecessaryObj(next.appState);
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const {
|
|
|
|
const keys = Object.keys(prevAppState) as (keyof Partial<AppState>)[];
|
|
|
|
canvas: _prevCanvas,
|
|
|
|
|
|
|
|
// not stable, but shouldn't matter in our case
|
|
|
|
|
|
|
|
onInsertElements: _prevOnInsertElements,
|
|
|
|
|
|
|
|
appState: prevAppState,
|
|
|
|
|
|
|
|
...prev
|
|
|
|
|
|
|
|
} = prevProps;
|
|
|
|
|
|
|
|
const {
|
|
|
|
|
|
|
|
canvas: _nextCanvas,
|
|
|
|
|
|
|
|
onInsertElements: _nextOnInsertElements,
|
|
|
|
|
|
|
|
appState: nextAppState,
|
|
|
|
|
|
|
|
...next
|
|
|
|
|
|
|
|
} = nextProps;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
isShallowEqual(
|
|
|
|
prev.renderTopRightUI === next.renderTopRightUI &&
|
|
|
|
stripIrrelevantAppStateProps(prevAppState),
|
|
|
|
prev.renderCustomStats === next.renderCustomStats &&
|
|
|
|
stripIrrelevantAppStateProps(nextAppState),
|
|
|
|
prev.renderCustomSidebar === next.renderCustomSidebar &&
|
|
|
|
) && isShallowEqual(prev, next)
|
|
|
|
prev.langCode === next.langCode &&
|
|
|
|
|
|
|
|
prev.elements === next.elements &&
|
|
|
|
|
|
|
|
prev.files === next.files &&
|
|
|
|
|
|
|
|
keys.every((key) => prevAppState[key] === nextAppState[key])
|
|
|
|
);
|
|
|
|
);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|