const { app, BrowserWindow, ipcMain, dialog } = require('electron'); const path = require('path'); let mainWindow; function createWindow() { mainWindow = new BrowserWindow({ width: 1200, height: 800, webPreferences: { nodeIntegration: true, contextIsolation: false, webviewTag: true } }); mainWindow.loadFile(path.join(__dirname, 'renderer/index.html')); mainWindow.setTitle('OneDrive Photos'); } app.whenReady().then(createWindow); app.on('window-all-closed', () => { if (process.platform !== 'darwin') { app.quit(); } }); app.on('activate', () => { if (BrowserWindow.getAllWindows().length === 0) { createWindow(); } }); // Modified IPC handlers ipcMain.on('toggle-config', () => { mainWindow.webContents.send('toggle-config'); }); ipcMain.on('set-config', (event, config) => { console.log('Destination Folder:', config.destFolder); console.log('OneDrive Source Path:', config.onedriveSource); }); ipcMain.on('select-folder', (event) => { dialog.showOpenDialog({ properties: ['openDirectory'] }).then(result => { if (!result.canceled) { event.reply('folder-selected', result.filePaths[0]); } }).catch(err => { console.log(err); }); });