mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2026-01-23 13:01:25 -08:00
fix: not restart after setting change
This commit is contained in:
parent
992a1afa3f
commit
6f0179a90e
1 changed files with 6 additions and 4 deletions
|
|
@ -9,6 +9,7 @@ export function useForm(
|
|||
requestRestartCountDown: () => void = () => {},
|
||||
): [IWorkspace | undefined, (newValue: IWorkspace, requestSaveAndRestart?: boolean) => void, () => Promise<void>] {
|
||||
const [workspace, workspaceSetter] = useState(originalWorkspace);
|
||||
const [requestRestartAfterSave, requestRestartAfterSaveSetter] = useState(false);
|
||||
const previous = usePreviousValue(originalWorkspace);
|
||||
// initial observable value maybe undefined, we pass an non-null initial value to the form
|
||||
useEffect(() => {
|
||||
|
|
@ -21,13 +22,14 @@ export function useForm(
|
|||
return;
|
||||
}
|
||||
await window.service.workspace.update(workspace.id, workspace);
|
||||
}, [workspace]);
|
||||
if (requestRestartAfterSave) {
|
||||
requestRestartCountDown();
|
||||
}
|
||||
}, [workspace, requestRestartAfterSave, requestRestartCountDown]);
|
||||
const setterWithRestartOption = (newValue: IWorkspace, requestSaveAndRestart?: boolean) => {
|
||||
workspaceSetter(newValue);
|
||||
if (requestSaveAndRestart === true && !isEqual(newValue, originalWorkspace)) {
|
||||
void onSave().then(() => {
|
||||
requestRestartCountDown();
|
||||
});
|
||||
requestRestartAfterSaveSetter(true);
|
||||
}
|
||||
};
|
||||
return [workspace, setterWithRestartOption, onSave];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue