Skip to content

Commit 3df14ae

Browse files
Implemented review comments.
1 parent 8795b7e commit 3df14ae

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

web/pgadmin/tools/erd/static/js/erd_tool/components/MainToolBar.jsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//
88
//////////////////////////////////////////////////////////////
99
import React, {useCallback, useEffect, useState} from 'react';
10+
import _ from 'lodash';
1011
import { styled } from '@mui/material/styles';
1112
import { Box, useTheme } from '@mui/material';
1213
import { PgButtonGroup, PgIconButton } from '../../../../../../static/js/components/Buttons';
@@ -164,7 +165,13 @@ export function MainToolBar({preferences, eventBus, fillColor, textColor, notati
164165
isDirtyRef.current = isDirty;
165166
setDisableButton('save', !isDirty);
166167
if((isDirty || fileName) && isSaveToolDataEnabled('ERD')){
167-
setSaveERDData({data, fileName, isDirty, toolbarPrefs});
168+
setSaveERDData((prev) => ({
169+
...prev,
170+
data,
171+
fileName,
172+
isDirty,
173+
...(toolbarPrefs !== undefined && { toolbarPrefs }),
174+
}));
168175
}
169176
}],
170177
];
@@ -179,8 +186,10 @@ export function MainToolBar({preferences, eventBus, fillColor, textColor, notati
179186
}, []);
180187

181188
const [saveERDData, setSaveERDData] = useState(null);
182-
useDelayDebounce(({data, fileName, isDirty, toolbarPrefs})=>{
183-
saveToolData('ERD', {...connectionInfo,'open_file_name':fileName, 'is_editor_dirty': isDirty, 'preferences': toolbarPrefs}, connectionInfo.trans_id, data);
189+
useDelayDebounce((saveData)=>{
190+
if(saveData?.data !== undefined){
191+
saveToolData('ERD', {...connectionInfo, 'open_file_name': saveData.fileName, 'is_editor_dirty': saveData.isDirty, 'preferences': saveData.toolbarPrefs}, connectionInfo.trans_id, saveData.data);
192+
}
184193
}, saveERDData, 500);
185194

186195
useEffect(()=>{

0 commit comments

Comments
 (0)