Refactor config and simplify error handling

- Moved several utility and configuration files (rpc.js, store.js, dimensions.js, and menu.js) to a new `config` directory to improve project organization.

- This refactor does not affect the functionality of the app.
This commit is contained in:
Agampreet Singh
2024-07-22 13:21:44 +05:30
parent 67d61a4cc9
commit dc5b3c86d5
6 changed files with 94 additions and 103 deletions

View File

@@ -1,19 +1,19 @@
import { app, Menu, BrowserWindow, dialog, nativeImage, screen } from "electron";
import { clearActivity, setActivity, loginToRPC } from "./rpc.js";
import { clearActivity, setActivity, loginToRPC } from "./config/rpc.js";
import { initialize, trackEvent } from "@aptabase/electron/main";
import { ElectronBlocker } from "@cliqz/adblocker-electron";
import { getValue } from "./store.js";
import { getValue } from "./config/store.js";
import { fileURLToPath } from "url";
import { dirname } from "path";
import { join } from "path";
import { getScreenWidth, getScreenHeight } from "./dimensions.js";
import { getScreenWidth, getScreenHeight } from "./config/dimensions.js";
import Windows from "./useragents.json" with { type: "json" };
import checkInternetConnected from "check-internet-connected";
import contextMenu from "electron-context-menu";
import updaterpkg from "electron-updater";
import ElectronDl from "electron-dl";
import menulayout from "./menu.js";
import menulayout from "./config/menu.js";
import logpkg from "electron-log";
const { transports, log: _log, functions } = logpkg;
@@ -122,11 +122,7 @@ app.on("web-contents-created", (event, contents) => {
if (url.includes("page=Download")) {
return { action: "allow" };
} else {
BrowserWindow.getFocusedWindow()
.loadURL(url)
.catch((err) => {
// do not show error
});
BrowserWindow.getFocusedWindow().loadURL(url).catch();
if (getValue("discordrpcstatus") === "true") {
setActivity(`On "${BrowserWindow.getFocusedWindow().webContents.getTitle()}"`);
}