2021-12-01 13:07:17 +05:00
|
|
|
const { ipcMain } = require("electron");
|
2021-08-05 12:05:16 +05:00
|
|
|
const { logger } = require("../logger");
|
2021-07-07 00:56:34 +05:00
|
|
|
const { getAction } = require("./actions");
|
2021-08-05 10:02:56 +05:00
|
|
|
const { getCall } = require("./calls");
|
2021-07-07 00:56:34 +05:00
|
|
|
|
|
|
|
|
ipcMain.on("fromRenderer", async (event, args) => {
|
2021-08-05 12:05:16 +05:00
|
|
|
logger.info("Action requested by renderer", args);
|
|
|
|
|
|
2021-07-07 00:56:34 +05:00
|
|
|
const { type } = args;
|
|
|
|
|
const action = getAction(type);
|
|
|
|
|
if (!action) return;
|
2021-08-05 10:02:56 +05:00
|
|
|
await action(args);
|
|
|
|
|
});
|
|
|
|
|
|
2021-12-01 13:07:17 +05:00
|
|
|
ipcMain.handle("fromRenderer", async (event, args) => {
|
2021-08-05 12:05:16 +05:00
|
|
|
logger.info("Call requested by renderer", args);
|
|
|
|
|
|
2021-08-05 10:02:56 +05:00
|
|
|
const { type } = args;
|
|
|
|
|
const call = getCall(type);
|
|
|
|
|
if (!call) return;
|
2021-12-01 13:07:17 +05:00
|
|
|
|
|
|
|
|
return await call(args, global.win);
|
2021-07-07 00:56:34 +05:00
|
|
|
});
|