{"size": 1659, "ext": "js", "max_stars_repo_path": "src/main/ipc-handlers/schedulers.js", "max_stars_repo_name": "andresiraola/antares", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/main/ipc-handlers/schedulers.js", "max_issues_repo_name": "andresiraola/antares", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/main/ipc-handlers/schedulers.js", "max_forks_repo_name": "andresiraola/antares", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 29.1052631579, "max_line_length": 83, "alphanum_fraction": 0.5473176612}
import { ipcMain } from 'electron';

export default (connections) => {
   ipcMain.handle('get-scheduler-informations', async (event, params) => {
      try {
         const result = await connections[params.uid].getEventInformations(params);
         return { status: 'success', response: result };
      }
      catch (err) {
         return { status: 'error', response: err.toString() };
      }
   });

   ipcMain.handle('drop-scheduler', async (event, params) => {
      try {
         await connections[params.uid].dropEvent(params);
         return { status: 'success' };
      }
      catch (err) {
         return { status: 'error', response: err.toString() };
      }
   });

   ipcMain.handle('alter-scheduler', async (event, params) => {
      try {
         await connections[params.uid].alterEvent(params);
         return { status: 'success' };
      }
      catch (err) {
         return { status: 'error', response: err.toString() };
      }
   });

   ipcMain.handle('create-scheduler', async (event, params) => {
      try {
         await connections[params.uid].createEvent(params);
         return { status: 'success' };
      }
      catch (err) {
         return { status: 'error', response: err.toString() };
      }
   });

   ipcMain.handle('toggle-scheduler', async (event, params) => {
      try {
         if (!params.enabled)
            await connections[params.uid].enableEvent({ ...params });
         else
            await connections[params.uid].disableEvent({ ...params });
         return { status: 'success' };
      }
      catch (err) {
         return { status: 'error', response: err.toString() };
      }
   });
};
