Fix env save dialog fallback
Some checks failed
Build Windows App / build-windows (push) Has been cancelled

This commit is contained in:
MrSphay
2026-05-02 00:53:13 +02:00
parent 0abe51b982
commit 77a69c180c
2 changed files with 35 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
import { app, BrowserWindow, Menu, dialog, ipcMain } from "electron";
import type { OpenDialogOptions } from "electron";
import type { OpenDialogOptions, SaveDialogOptions } from "electron";
import { readFile, writeFile } from "node:fs/promises";
import path from "node:path";
import { fileURLToPath } from "node:url";
@@ -55,11 +55,17 @@ ipcMain.handle("envhelper:open-file", async (event) => {
};
});
ipcMain.handle("envhelper:save-file", async (_event, content: string) => {
const result = await dialog.showSaveDialog({
ipcMain.handle("envhelper:save-file", async (event, content: string) => {
const owner = BrowserWindow.fromWebContents(event.sender);
const options = {
defaultPath: ".env",
filters: [{ name: "Environment file", extensions: ["env"] }]
});
filters: [
{ name: "Environment files", extensions: ["env", "txt"] },
{ name: "All files", extensions: ["*"] }
]
} satisfies SaveDialogOptions;
const result = owner ? await dialog.showSaveDialog(owner, options) : await dialog.showSaveDialog(options);
if (result.canceled || !result.filePath) {
return null;