mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-24 09:28:31 +00:00
compute the diff and update it to the store
This commit is contained in:
parent
dbb330c16b
commit
1fd08cac6c
2 changed files with 12 additions and 7 deletions
|
|
@ -93,7 +93,7 @@ const EditorComponent = (props) => {
|
|||
const { socket } = createWebsocketConnection(props?.params?.id);
|
||||
const mounted = useMounted();
|
||||
|
||||
const { updateState } = useAppDataActions();
|
||||
const { updateState, updateAppDefinitionDiff } = useAppDataActions();
|
||||
const { updateEditorState, updateQueryConfirmationList } = useEditorActions();
|
||||
const {
|
||||
noOfVersionsSupported,
|
||||
|
|
@ -115,7 +115,7 @@ const EditorComponent = (props) => {
|
|||
|
||||
const dataQueries = useDataQueries();
|
||||
|
||||
const { isMaintenanceOn, appId, app, currentUser, currentVersionId } = useAppInfo();
|
||||
const { isMaintenanceOn, appId, app, currentUser, currentVersionId, appDefinitionDiff } = useAppInfo();
|
||||
|
||||
const [currentVersionChanges, setCurrentVersionChanges] = useState({});
|
||||
const [currentPageId, setCurrentPageId] = useState(null);
|
||||
|
|
@ -722,16 +722,20 @@ const EditorComponent = (props) => {
|
|||
updatedAppDefinition.pages[currentPageId].components = currentPageComponents;
|
||||
|
||||
const diffPatches = diff(appDefinition, updatedAppDefinition);
|
||||
const shouldUpdate = !_.isEmpty(diffPatches) && !isEqual(appDefinitionDiff, diffPatches);
|
||||
|
||||
console.log('--arpit | appDefinitionChanged func() | diffPatches', {
|
||||
diffPatches,
|
||||
});
|
||||
// console.log('--arpit | appDefinitionChanged func() | diffPatches', {
|
||||
// diffPatches,
|
||||
// appDefinitionDiff,
|
||||
// shouldUpdate,
|
||||
// });
|
||||
|
||||
if (!_.isEmpty(diffPatches)) {
|
||||
if (shouldUpdate) {
|
||||
updateEditorState({
|
||||
isSaving: true,
|
||||
appDefinition: updatedAppDefinition,
|
||||
});
|
||||
updateAppDefinitionDiff(diffPatches);
|
||||
computeComponentState(updatedAppDefinition.pages[currentPageId]?.components);
|
||||
}
|
||||
|
||||
|
|
@ -890,7 +894,6 @@ const EditorComponent = (props) => {
|
|||
const diffPatches = diff(appDefinition, updatedAppDefinition);
|
||||
|
||||
if (!isEmpty(diffPatches)) {
|
||||
// handleAddPatch(diffPatches, diff(updatedAppDefinition, appDefinition));
|
||||
appDefinitionChanged(updatedAppDefinition, { skipAutoSave: true, componentDefinitionChanged: true });
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ const initialState = {
|
|||
pages: [],
|
||||
layouts: [],
|
||||
eventHandlers: [],
|
||||
appDefinitionDiff: null,
|
||||
};
|
||||
|
||||
export const useAppDataStore = create(
|
||||
|
|
@ -28,6 +29,7 @@ export const useAppDataStore = create(
|
|||
updateEditingVersion: (version) => set(() => ({ editingVersion: version })),
|
||||
updateApps: (apps) => set(() => ({ apps: apps })),
|
||||
updateState: (state) => set((prev) => ({ ...prev, ...state })),
|
||||
updateAppDefinitionDiff: (appDefinitionDiff) => set(() => ({ appDefinitionDiff: appDefinitionDiff })),
|
||||
},
|
||||
}),
|
||||
{ name: 'App Data Store' }
|
||||
|
|
|
|||
Loading…
Reference in a new issue