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

This commit is contained in:
MrSphay
2026-05-01 23:54:51 +02:00
parent c7711096ea
commit 1be74d1ad3
2 changed files with 54 additions and 6 deletions

View File

@@ -1,4 +1,5 @@
import { app, BrowserWindow, Menu, dialog, ipcMain } from "electron";
import type { OpenDialogOptions } from "electron";
import { readFile, writeFile } from "node:fs/promises";
import path from "node:path";
import { fileURLToPath } from "node:url";
@@ -31,11 +32,17 @@ async function createWindow() {
}
}
ipcMain.handle("envhelper:open-file", async () => {
const result = await dialog.showOpenDialog({
ipcMain.handle("envhelper:open-file", async (event) => {
const owner = BrowserWindow.fromWebContents(event.sender);
const options = {
properties: ["openFile"],
filters: [{ name: "Environment files", extensions: ["env", "txt", "*"] }]
});
filters: [
{ name: "Environment files", extensions: ["env", "txt"] },
{ name: "All files", extensions: ["*"] }
]
} satisfies OpenDialogOptions;
const result = owner ? await dialog.showOpenDialog(owner, options) : await dialog.showOpenDialog(options);
if (result.canceled || result.filePaths.length === 0) {
return null;