feat(editor): preserve unsaved SQL drafts on exit
This commit is contained in:
1 parent
52c892676c
commit
31a50fb460
17 files changed
+313
-3
No files matched your search
@@ -2300,9 +2300,16 @@ export const useQueryStore = defineStore("query", () => {
|
||||
|
||||
const hasDirtyTabs = computed(() => tabs.value.some((tab) => isTabDirty(tab)));
|
||||
const shouldConfirmUnsavedSqlClose = computed(() => useSettingsStore().editorSettings.confirmUnsavedSqlClose);
|
||||
const keepUnsavedTabsDraftsOnAppClose = computed(() => useSettingsStore().editorSettings.appCloseUnsavedTabsMode === "keep-drafts");
|
||||
const requiresAppCloseDraftPersist = computed(() => shouldConfirmUnsavedSqlClose.value && keepUnsavedTabsDraftsOnAppClose.value && tabs.value.some((tab) => tab.mode === "query" && isTabDirty(tab)));
|
||||
|
||||
function shouldConfirmTabOnAppClose(tab: QueryTab): boolean {
|
||||
if (!shouldConfirmTabClose(tab)) return false;
|
||||
return !keepUnsavedTabsDraftsOnAppClose.value || tab.mode !== "query";
|
||||
}
|
||||
|
||||
const closeConfirmDirtyTabIds = computed(() => {
|
||||
if (isConfirmingAppClose.value) return tabs.value.filter((tab) => isTabDirty(tab)).map((tab) => tab.id);
|
||||
if (isConfirmingAppClose.value) return tabs.value.filter((tab) => shouldConfirmTabOnAppClose(tab)).map((tab) => tab.id);
|
||||
if (pendingBatchCloseTabIds.value) {
|
||||
return pendingBatchCloseTabIds.value
|
||||
.map((id) => tabs.value.find((tab) => tab.id === id))
|
||||
@@ -2670,7 +2677,7 @@ export const useQueryStore = defineStore("query", () => {
|
||||
}
|
||||
|
||||
function requestAppCloseConfirmation() {
|
||||
const dirtyTab = tabs.value.find((tab) => shouldConfirmTabClose(tab));
|
||||
const dirtyTab = tabs.value.find((tab) => shouldConfirmTabOnAppClose(tab));
|
||||
if (!dirtyTab) return false;
|
||||
isConfirmingAppClose.value = true;
|
||||
showDirtyTabCloseConfirm(dirtyTab, "app");
|
||||
@@ -6290,6 +6297,7 @@ export const useQueryStore = defineStore("query", () => {
|
||||
closeConfirmContext,
|
||||
closeConfirmDirtyTabIds,
|
||||
hasDirtyTabs,
|
||||
requiresAppCloseDraftPersist,
|
||||
isConfirmingAppClose,
|
||||
createTab,
|
||||
openObjectSourceTab,
|
||||
|
||||
Reference in new issue
Block a user