aboutsummaryrefslogtreecommitdiff
path: root/src/modules/ipc.js
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2024-02-04 15:40:23 +0100
committer0neGal <mail@0negal.com>2024-02-04 15:46:55 +0100
commite8e502cc574fdd6eaa54a3a25c2d975596c13026 (patch)
treed193b02d9f37afe109a497b99b6bffc54a5cab64 /src/modules/ipc.js
parentceda605611c9ec2fbe858f3ae29942d56a06ac66 (diff)
downloadViper-e8e502cc574fdd6eaa54a3a25c2d975596c13026.tar.gz
Viper-e8e502cc574fdd6eaa54a3a25c2d975596c13026.zip
move IPC events into their respective modules
I've not been able to find anything that breaks from this, as I've gone through every IPC event that got moved, to ensure it still functions, and all the breakage I found has since been fixed. IPC events that dont fit in any particular module is also now in the new file named `src/app/modules/ipc.js` There's also another module `src/win.js`, which lets you get the `BrowserWindow` outside of `src/index.js` I also took the oppertunity to clean up some of the code when moving it around, and adding a couple comments, as some of it was quite horrid.
Diffstat (limited to 'src/modules/ipc.js')
-rw-r--r--src/modules/ipc.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/modules/ipc.js b/src/modules/ipc.js
new file mode 100644
index 0000000..55737b7
--- /dev/null
+++ b/src/modules/ipc.js
@@ -0,0 +1,32 @@
+const win = require("../win");
+const { app, ipcMain } = require("electron");
+
+const kill = require("./kill");
+const settings = require("./settings");
+const is_running = require("./is_running");
+
+ipcMain.on("exit", () => {
+ if (settings().originkill) {
+ is_running.origin().then((running) => {
+ if (running) {
+ kill.origin().then(process.exit(0));
+ } else {
+ process.exit(0) ;
+ }
+ })
+ } else {
+ process.exit(0);
+ }
+})
+
+ipcMain.on("minimize", () => {
+ win().minimize();
+})
+
+ipcMain.on("relaunch", () => {
+ app.relaunch({
+ args: process.argv.slice(1)
+ })
+
+ app.exit(0);
+})