From 48bab037088255c6be1c8fe927e076ca29b52a91 Mon Sep 17 00:00:00 2001 From: Agampreet Singh <68941022+agam778@users.noreply.github.com> Date: Wed, 8 May 2024 00:59:05 +0530 Subject: [PATCH] Refactor main window creation and configuration --- app/main.js | 49 ++++++++++++++++--------------------------------- 1 file changed, 16 insertions(+), 33 deletions(-) diff --git a/app/main.js b/app/main.js index 204495c..3337cb0 100644 --- a/app/main.js +++ b/app/main.js @@ -27,39 +27,22 @@ Object.assign(console, functions); initialize("A-US-2528580917"); function createWindow() { - if (getValue("enterprise-or-normal") === "https://microsoft365.com/?auth=1") { - var win = new BrowserWindow({ - width: 1181, - height: 670, - icon: join(__dirname, "/assets/icons/png/1024x1024.png"), - show: false, - webPreferences: { - nodeIntegration: true, - devTools: true, - partition: "persist:personal", - }, - }); - } else if ( - getValue("enterprise-or-normal") === "https://microsoft365.com/?auth=2" - ) { - var win = new BrowserWindow({ - width: 1181, - height: 670, - icon: join(__dirname, "/assets/icons/png/1024x1024.png"), - show: false, - webPreferences: { - nodeIntegration: true, - devTools: true, - partition: "persist:work", - }, - }); - } - - if (getValue("autohide-menubar") === "true") { - win.setAutoHideMenuBar(true); - } else { - win.setAutoHideMenuBar(false); - } + const enterpriseOrNormal = getValue("enterprise-or-normal"); + const partition = enterpriseOrNormal === "https://microsoft365.com/?auth=1" ? "persist:personal" : "persist:work"; + + const win = new BrowserWindow({ + width: 1181, + height: 670, + icon: join(__dirname, "/assets/icons/png/1024x1024.png"), + show: false, + webPreferences: { + nodeIntegration: true, + devTools: true, + partition: partition, + }, + }); + + win.setAutoHideMenuBar(getValue("autohide-menubar") === "true"); const splash = new BrowserWindow({ width: 810,