Skip to content

Commit

Permalink
fix logic
Browse files Browse the repository at this point in the history
  • Loading branch information
esimkowitz committed Dec 20, 2024
1 parent a8d30d1 commit a9be94a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 27 deletions.
42 changes: 19 additions & 23 deletions emain/emain-window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,24 +230,25 @@ export class WaveBrowserWindow extends BaseWindow {
fireAndForget(async () => {
const numWindows = waveWindowMap.size;
const fullConfig = await FileService.GetFullConfig();
if (
fullConfig.settings["window:confirmonclose"] &&
(numWindows > 1 || !fullConfig.settings["window:savelastwindowonclose"])
) {
console.log("numWindows > 1", numWindows);
const workspace = await WorkspaceService.GetWorkspace(this.workspaceId);
console.log("workspace", workspace);
if (isNonEmptyUnsavedWorkspace(workspace)) {
console.log("workspace has no name, icon, and multiple tabs", workspace);
const choice = dialog.showMessageBoxSync(this, {
type: "question",
buttons: ["Cancel", "Close Window"],
title: "Confirm",
message: "Window has unsaved tabs, closing window will delete existing tabs.\n\nContinue?",
});
if (choice === 0) {
console.log("user cancelled close window", this.waveWindowId);
return;
if (numWindows > 1 || !fullConfig.settings["window:savelastwindowonclose"]) {
console.log("numWindows > 1 or user does not want last window saved", numWindows);
if (fullConfig.settings["window:confirmclose"]) {
console.log("confirmclose", this.waveWindowId);
const workspace = await WorkspaceService.GetWorkspace(this.workspaceId);
console.log("workspace", workspace);
if (isNonEmptyUnsavedWorkspace(workspace)) {
console.log("workspace has no name, icon, and multiple tabs", workspace);
const choice = dialog.showMessageBoxSync(this, {
type: "question",
buttons: ["Cancel", "Close Window"],
title: "Confirm",
message:
"Window has unsaved tabs, closing window will delete existing tabs.\n\nContinue?",
});
if (choice === 0) {
console.log("user cancelled close window", this.waveWindowId);
return;
}
}
}
console.log("deleteAllowed = true", this.waveWindowId);
Expand All @@ -274,11 +275,6 @@ export class WaveBrowserWindow extends BaseWindow {
this.destroy();
return;
}
const numWindows = waveWindowMap.size;
if (numWindows == 0) {
console.log("win no windows left", this.waveWindowId);
return;
}
if (this.deleteAllowed) {
console.log("win removing window from backend DB", this.waveWindowId);
fireAndForget(() => WindowService.CloseWindow(this.waveWindowId, true));
Expand Down
2 changes: 1 addition & 1 deletion frontend/types/gotypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ declare global {
"window:magnifiedblocksize"?: number;
"window:magnifiedblockblurprimarypx"?: number;
"window:magnifiedblockblursecondarypx"?: number;
"window:confirmonclose"?: boolean;
"window:confirmclose"?: boolean;
"window:savelastwindowonclose"?: boolean;
"telemetry:*"?: boolean;
"telemetry:enabled"?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion pkg/wconfig/defaultconfig/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"window:magnifiedblocksize": 0.9,
"window:magnifiedblockblurprimarypx": 10,
"window:magnifiedblockblursecondarypx": 2,
"window:confirmonclose": true,
"window:confirmclose": true,
"window:savelastwindowonclose": true,
"telemetry:enabled": true,
"term:copyonselect": true
Expand Down
2 changes: 1 addition & 1 deletion pkg/wconfig/metaconsts.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const (
ConfigKey_WindowMagnifiedBlockSize = "window:magnifiedblocksize"
ConfigKey_WindowMagnifiedBlockBlurPrimaryPx = "window:magnifiedblockblurprimarypx"
ConfigKey_WindowMagnifiedBlockBlurSecondaryPx = "window:magnifiedblockblursecondarypx"
ConfigKey_WindowConfirmOnClose = "window:confirmonclose"
ConfigKey_WindowConfirmClose = "window:confirmclose"
ConfigKey_WindowSaveLastWindowOnClose = "window:savelastwindowonclose"

ConfigKey_TelemetryClear = "telemetry:*"
Expand Down
2 changes: 1 addition & 1 deletion pkg/wconfig/settingsconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ type SettingsType struct {
WindowMagnifiedBlockSize *float64 `json:"window:magnifiedblocksize,omitempty"`
WindowMagnifiedBlockBlurPrimaryPx *int64 `json:"window:magnifiedblockblurprimarypx,omitempty"`
WindowMagnifiedBlockBlurSecondaryPx *int64 `json:"window:magnifiedblockblursecondarypx,omitempty"`
WindowConfirmOnClose bool `json:"window:confirmonclose,omitempty"`
WindowConfirmClose bool `json:"window:confirmclose,omitempty"`
WindowSaveLastWindowOnClose bool `json:"window:savelastwindowonclose,omitempty"`

TelemetryClear bool `json:"telemetry:*,omitempty"`
Expand Down

0 comments on commit a9be94a

Please sign in to comment.