This commit is contained in:
2021-08-05 13:41:51 -05:00
parent e23c0086c2
commit 33f9ffb393
76 changed files with 1390 additions and 1388 deletions
+36 -36
View File
@@ -1,55 +1,55 @@
const Constants = require('../../constants');
const helpers = require('../../helpers');
const addListeners = (ipcMain, {standardIPCReply}) => {
const addListeners = (ipcMain, { standardIPCReply }) => {
ipcMain.on(Constants.IPC_Get_Config, (event, data) => {
helpers
.getConfig(data.Version, data.Provider, data.Remote, data.S3)
.then((data) => {
if (data.Code === 0) {
standardIPCReply(event, Constants.IPC_Get_Config_Reply, {
Config: data.Data,
});
} else {
standardIPCReply(event, Constants.IPC_Get_Config_Reply, {}, data.Code);
}
})
.catch((error) => {
standardIPCReply(event, Constants.IPC_Get_Config_Reply, {}, error);
});
.getConfig(data.Version, data.Provider, data.Remote, data.S3)
.then((data) => {
if (data.Code === 0) {
standardIPCReply(event, Constants.IPC_Get_Config_Reply, {
Config: data.Data,
});
} else {
standardIPCReply(event, Constants.IPC_Get_Config_Reply, {}, data.Code);
}
})
.catch((error) => {
standardIPCReply(event, Constants.IPC_Get_Config_Reply, {}, error);
});
});
ipcMain.on(Constants.IPC_Get_Config_Template, (event, data) => {
helpers
.getConfigTemplate(data.Version, data.Provider, data.Remote, data.S3)
.then((data) => {
standardIPCReply(event, Constants.IPC_Get_Config_Template_Reply, {
Template: data,
.getConfigTemplate(data.Version, data.Provider, data.Remote, data.S3)
.then((data) => {
standardIPCReply(event, Constants.IPC_Get_Config_Template_Reply, {
Template: data,
});
})
.catch((error) => {
standardIPCReply(event, Constants.IPC_Get_Config_Template_Reply, {}, error);
});
})
.catch((error) => {
standardIPCReply(event, Constants.IPC_Get_Config_Template_Reply, {}, error);
});
});
ipcMain.on(Constants.IPC_Set_Config_Values, (event, data) => {
const setConfigValue = (i) => {
if (i < data.Items.length) {
helpers
.setConfigValue(
data.Items[i].Name,
data.Items[i].Value,
data.Provider,
data.Remote,
data.S3,
data.Version
)
.then(() => {
setConfigValue(++i);
})
.catch((error) => {
standardIPCReply(event, Constants.IPC_Set_Config_Values_Reply, {}, error);
});
.setConfigValue(
data.Items[i].Name,
data.Items[i].Value,
data.Provider,
data.Remote,
data.S3,
data.Version
)
.then(() => {
setConfigValue(++i);
})
.catch((error) => {
standardIPCReply(event, Constants.IPC_Set_Config_Values_Reply, {}, error);
});
} else {
standardIPCReply(event, Constants.IPC_Set_Config_Values_Reply, {});
}