Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions apps/desktop/main/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { app, BrowserWindow, dialog, ipcMain, Menu, screen, shell } from "electron";
import { app, BrowserWindow, dialog, ipcMain, Menu, Rectangle, screen, shell } from "electron";
import { setupEventListeners } from "./app/events";
import { windows } from "./app/windows";
import { join } from "path";
import { format } from "url";
import { environment } from "./environments/environment";
import log from "electron-log";
import * as Store from "electron-store";

const { ELECTRON_IS_DEV } = process.env;

Expand All @@ -29,6 +30,8 @@ const rendererAppDevPort = 4200;
*/
const desktopFrontendFile = (fileName: string) => join(__dirname, "frontend", fileName);

const config = new Store();

function createFrontendWindow() {
const workAreaSize = screen.getPrimaryDisplay().workAreaSize;
const width = Math.min(DEFAULT_WIDTH, workAreaSize.width || DEFAULT_WIDTH);
Expand All @@ -53,10 +56,18 @@ function createFrontendWindow() {
contextIsolation: false,
},
});
frontend.center();
const bounds = config.get('frontendBounds') as Rectangle;
if (bounds) {
frontend.setBounds(bounds);
} else {
frontend.center();
}
frontend.on("ready-to-show", () => {
windows.frontend?.show();
});
frontend.on("close", () => {
config.set('frontendBounds', frontend.getBounds());
});
frontend.on("closed", () => {
windows.frontend = null;
app.quit();
Expand Down