const Constants = require('../../constants'); const helpers = require('../../helpers'); const addListeners = (ipcMain, { standardIPCReply }) => { ipcMain.on(Constants.IPC_Get_Directory_Items, (event, data) => { helpers .grabDirectoryItems( data.Path, data.Version, data.Provider, data.Remote, data.S3 ) .then((data) => { standardIPCReply(event, Constants.IPC_Get_Directory_Items_Reply, { Items: data.items, }); }) .catch((e) => { standardIPCReply(event, Constants.IPC_Get_Directory_Items_Reply, {}, e); }); }); ipcMain.on(Constants.IPC_Get_Pinned_Files, (event, data) => { helpers .grabDirectoryItems( data.Path, data.Version, data.Provider, data.Remote, data.S3 ) .then((data) => { standardIPCReply(event, Constants.IPC_Get_Directory_Items_Reply, { Items: data.items, }); }) .catch((e) => { standardIPCReply(event, Constants.IPC_Get_Directory_Items_Reply, {}, e); }); }); ipcMain.on(Constants.IPC_Get_Pinned_Files_Status, (event, data) => {}); ipcMain.on(Constants.IPC_Set_Pinned + '_sync', (event, data) => { helpers .setPinned( data.Path, data.Pinned, data.Version, data.Provider, data.Remote, data.S3 ) .then((success) => { event.returnValue = success; }) .catch((e) => { event.returnValue = false; }); }); }; module.exports = { addListeners };