-1
src-tauri/src/lib.rs
-1
src-tauri/src/lib.rs
+36
src/Mangers/NodeManager.tsx
+36
src/Mangers/NodeManager.tsx
···
7
7
import { NodesByID } from "../Nodes/Nodes";
8
8
import { save } from "@tauri-apps/plugin-dialog";
9
9
import { ConfirmationManager } from "./ConfirmationManager";
10
+
import { getCurrentWindow } from "@tauri-apps/api/window";
10
11
11
12
export interface TabHashMap {
12
13
[details: string] : Tab;
···
40
41
}));
41
42
};
42
43
});
44
+
45
+
(async () => {
46
+
let window = await getCurrentWindow();
47
+
48
+
window.onCloseRequested(async ev => {
49
+
ev.preventDefault();
50
+
51
+
let tabs = Object.values(this._tabs);
52
+
let tabsNeedingSaving = tabs.filter(x => x.needsSave());
53
+
54
+
for(let tab of tabsNeedingSaving){
55
+
await new Promise<void>(res => {
56
+
ConfirmationManager.Instance.ShowConfirmation(
57
+
`Discard Changes in ${tab.name}?`,
58
+
'If you close this tab without saving you will lose all changes.',
59
+
[
60
+
{
61
+
text: 'Save',
62
+
callback: async () => {
63
+
await this.SaveTab(tab);
64
+
res();
65
+
}
66
+
},
67
+
{
68
+
text: 'Don\'t Save',
69
+
callback: () => { res(); }
70
+
}
71
+
]
72
+
)
73
+
});
74
+
}
75
+
76
+
window.close();
77
+
});
78
+
})();
43
79
}
44
80
45
81