fix(settings): report apply failures without stalling

This commit is contained in:
jearhe authored and GitHub committed 2026-08-18 10:50:47 +08:00
1 parent 840082d73b
commit cddc6a2c40
10 files changed
+74 -3

No files matched your search

@@ -984,13 +984,34 @@ async function persistSettings() {
}
}
function applySettingsErrorToast(error: unknown) {
toast(t("settings.applyFailed", { error: error instanceof Error ? error.message : String(error) }), 5000);
}
// Shared apply entrypoint used by both "Apply" and "Apply & Close". Persists the
// current draft and reports failure explicitly instead of silently swallowing it
// (persistSettings() has several awaited persistence steps with no try/catch, so a
// rejected save used to leave "Apply" silent and made "Apply & Close" unclosable with
// no feedback). Returns whether persistence succeeded so the close path only proceeds
// once the settings are actually saved.
async function applySettingsForResult(): Promise<boolean> {
try {
await persistSettings();
return true;
} catch (error) {
applySettingsErrorToast(error);
return false;
}
}
async function applySettings() {
await persistSettings();
await applySettingsForResult();
}
async function applySettingsAndClose() {
await persistSettings();
closeSettings();
if (await applySettingsForResult()) {
closeSettings();
}
}
async function restartDbxForDuckDbIsolation() {