Skip to content

Commit

Permalink
Merge branch 'AbanobNageh-remember-maximize-settings'
Browse files Browse the repository at this point in the history
  • Loading branch information
gmastergreatee committed Mar 23, 2024
2 parents 093d0a5 + 89896c2 commit 53340ad
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
21 changes: 20 additions & 1 deletion js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ app = new Vue({
showWebPage: false,
showTestResults: false,
showConsole: false,
isMaximized: false,
},

iframe_working: false,
Expand Down Expand Up @@ -2532,6 +2533,16 @@ window.electronAPI.log((event, text, more_text = "") => {
}
});

window.electronAPI.onAppMaximized(() => {
appOptionsChanged = true;
app.app_options.isMaximized = true;
});

window.electronAPI.onAppUnMaximized(() => {
appOptionsChanged = true;
app.app_options.isMaximized = false;
});

//#endregion

//#region Electron API wrappers
Expand All @@ -2556,6 +2567,10 @@ function toggleFullScreen() {
window.electronAPI.toggleFullScreen();
}

function maximizeApp() {
window.electronAPI.maximizeApp();
}

/**
* Returns the root directory of the app
* @returns {Promise<string>} Root-directory path
Expand Down Expand Up @@ -2677,7 +2692,7 @@ async function loadAllConfigs() {
displayChapterNumbers: false,
});

loadConfigData("app_options", {
await loadConfigData("app_options", {
darkMode: true,
showNewOnly: false,
showCheckUpdatedOnly: false,
Expand All @@ -2686,7 +2701,11 @@ async function loadAllConfigs() {
showWebPage: false,
showTestResults: false,
showConsole: false,
isMaximized: false,
});
if (app.app_options.isMaximized) {
maximizeApp();
}

await loadConfigArrayData("rules");
app.loading_rules = false;
Expand Down
15 changes: 15 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ const createWindow = () => {
mainWindow.on("ready-to-show", () => {
mainWindow.show();

mainWindow.on('maximize', () => {
mainWindow.webContents.send("on-app-maximized");
});

mainWindow.on('unmaximize', () => {
mainWindow.webContents.send("on-app-unmaximized");
});

//#region Disabling CORS
session.defaultSession.webRequest.onHeadersReceived((details, callback) => {
let url = details.url.toLowerCase();
Expand Down Expand Up @@ -183,6 +191,7 @@ function handleComs() {
ipcMain.on("block-includes", urlIncludesToBlock);
ipcMain.on("toggle-fullscreen", toggleFullScreen);
ipcMain.on("app-relaunch", relaunchApp);
ipcMain.on("maximize-app", maximizeApp);
ipcMain.on("start-check-captcha", startCheckCaptcha);
ipcMain.on("stop-check-captcha", stopCheckCaptcha);
ipcMain.handle("dir-create", createDirectory);
Expand Down Expand Up @@ -312,6 +321,12 @@ async function updateApp(e, appZipUrl = "") {
}
}

function maximizeApp() {
if (!mainWindow.isMaximized()) {
mainWindow.maximize();
}
}

function relaunchApp() {
app.relaunch();
app.exit();
Expand Down
3 changes: 3 additions & 0 deletions preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ contextBridge.exposeInMainWorld("electronAPI", {
urlIncludesToBlock: (includes) =>
ipcRenderer.send("block-includes", includes),
toggleFullScreen: () => ipcRenderer.send("toggle-fullscreen"),
maximizeApp: () => ipcRenderer.send("maximize-app"),
startCheckCaptcha: () => ipcRenderer.send("start-check-captcha"),
stopCheckCaptcha: () => ipcRenderer.send("stop-check-captcha"),

Expand All @@ -40,4 +41,6 @@ contextBridge.exposeInMainWorld("electronAPI", {

// --- main to renderer
log: (callback) => ipcRenderer.on("log-message", callback),
onAppMaximized: (callback) => ipcRenderer.on("on-app-maximized", callback),
onAppUnMaximized: (callback) => ipcRenderer.on("on-app-unmaximized", callback),
});

0 comments on commit 53340ad

Please sign in to comment.