aboutsummaryrefslogtreecommitdiff
path: root/src/modules/settings.js
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2023-09-13 17:32:16 +0200
committer0neGal <mail@0negal.com>2023-09-13 17:32:16 +0200
commit2302d7055a11adefe15bdaa5d8f94324d2fe293f (patch)
tree2c464faadd1bd3cfedf0a234afbd10f0100c8035 /src/modules/settings.js
parent14279b484ee8acbe440e09be25c36f8527592e75 (diff)
downloadViper-2302d7055a11adefe15bdaa5d8f94324d2fe293f.tar.gz
Viper-2302d7055a11adefe15bdaa5d8f94324d2fe293f.zip
synchronize changes to settings from main process
If the main process has changes to the settings, said settings will now also be sent to the renderer, making them synchronized.
Diffstat (limited to 'src/modules/settings.js')
-rw-r--r--src/modules/settings.js8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/modules/settings.js b/src/modules/settings.js
index 3833e4f..e1f68c6 100644
--- a/src/modules/settings.js
+++ b/src/modules/settings.js
@@ -1,6 +1,6 @@
const fs = require("fs");
const path = require("path");
-const app = require("electron").app;
+const { app, ipcMain } = require("electron");
const json = require("./json");
const lang = require("../lang");
@@ -58,7 +58,7 @@ if (fs.existsSync("viper.json")) {
//
// you can also pass a settings object to the function and it'll try and
// merge it together with the already existing settings
-settings.save = (obj = {}) => {
+settings.save = (obj = {}, notify_renderer = true) => {
// refuse to save if settings aren't valid
if (invalid_settings) {
return false;
@@ -88,6 +88,10 @@ settings.save = (obj = {}) => {
settings.gamepath, "ns_startup_args.txt"
), settings.nsargs);
}
+
+ if (notify_renderer) {
+ ipcMain.emit("saved-settings", settings_content);
+ }
}
module.exports = settings;