mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-27 07:56:28 +00:00
fix designer save
This commit is contained in:
@@ -38,12 +38,13 @@ export default function Designer({ value, onChange }) {
|
|||||||
|
|
||||||
const changeTable = React.useCallback(
|
const changeTable = React.useCallback(
|
||||||
(table) => {
|
(table) => {
|
||||||
onChange((current) => ({
|
const newValue = {
|
||||||
...current,
|
...value,
|
||||||
tables: (current.tables || []).map((x) => (x.designerId == table.designerId ? table : x)),
|
tables: (value.tables || []).map((x) => (x.designerId == table.designerId ? table : x)),
|
||||||
}));
|
};
|
||||||
|
onChange(newValue);
|
||||||
},
|
},
|
||||||
[onChange]
|
[onChange, value]
|
||||||
);
|
);
|
||||||
|
|
||||||
const bringToFront = React.useCallback(
|
const bringToFront = React.useCallback(
|
||||||
|
|||||||
@@ -49,13 +49,12 @@ export default function useEditorData({ tabid, reloadToken = 0, loadFromArgs = n
|
|||||||
} else {
|
} else {
|
||||||
const initFallback = getParsedLocalStorage(localStorageKey);
|
const initFallback = getParsedLocalStorage(localStorageKey);
|
||||||
if (initFallback != null) {
|
if (initFallback != null) {
|
||||||
const init = JSON.parse(initFallback);
|
setValue(initFallback);
|
||||||
setValue(init);
|
valueRef.current = initFallback;
|
||||||
valueRef.current = init;
|
|
||||||
// move to local forage
|
// move to local forage
|
||||||
await localforage.setItem(localStorageKey, init);
|
await localforage.setItem(localStorageKey, initFallback);
|
||||||
localStorage.removeItem(localStorageKey);
|
localStorage.removeItem(localStorageKey);
|
||||||
initialDataRef.current = init;
|
initialDataRef.current = initFallback;
|
||||||
} else {
|
} else {
|
||||||
const init = await localforage.getItem(localStorageKey);
|
const init = await localforage.getItem(localStorageKey);
|
||||||
if (init) {
|
if (init) {
|
||||||
|
|||||||
Reference in New Issue
Block a user