Skip to content

Commit 68e415e

Browse files
committed
refactor history components to exclude nodeIntegration
1 parent 5d6dff4 commit 68e415e

File tree

9 files changed

+378
-2230
lines changed

9 files changed

+378
-2230
lines changed

main.js

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,12 @@ function createWindow() {
201201
title: "Swell",
202202
allowRunningInsecureContent: true,
203203
webPreferences: {
204-
nodeIntegration: true,
205-
sandbox: false,
204+
nodeIntegration: false,
205+
contextIsolation: true,
206+
enableRemoteModule: false,
207+
sandbox: true,
206208
webSecurity: true,
209+
preload: path.resolve(__dirname, 'preload.js')
207210
},
208211
icon: `${__dirname}/src/assets/icons/64x64.png`,
209212
});
@@ -274,6 +277,8 @@ function createWindow() {
274277
************** EVENT LISTENERS **********
275278
****************************************/
276279

280+
281+
277282
// app.on('ready') will be called when Electron has finished
278283
// initialization and is ready to create browser windows.
279284
// Some APIs can only be used after this event occurs.
@@ -297,6 +302,11 @@ app.on("window-all-closed", () => {
297302
}
298303
});
299304

305+
ipcMain.on('toMain', (e, args) => {
306+
console.log('received from ipcRenderer inside main: ', args);
307+
mainWindow.webContents.send('fromMain', `sending ${args} back to ipcRenderer`);
308+
})
309+
300310
// Auto Updating Functionality
301311
const sendStatusToWindow = (text) => {
302312
log.info(text);
@@ -452,11 +462,27 @@ ipcMain.on("import-collection", (event, args) => {
452462
}
453463

454464
// send data to chromium for state update
455-
event.sender.send("add-collection", { data });
465+
ipcMain.send("add-collection", { data });
456466
});
457467
});
458468
});
459469

470+
// ============ CONFIRM CLEAR HISTORY / RESPONSE COMMUNICATION ===============
471+
ipcMain.on('confirm-clear-history', (event) => {
472+
const opts = {
473+
type: "warning",
474+
buttons: ["Okay", "Cancel"],
475+
message: "Are you sure you want to clear history?",
476+
};
477+
478+
dialog.showMessageBox(null, opts)
479+
.then((response) => {
480+
console.log('response to clear-history : ', response)
481+
mainWindow.webContents.send('clear-history-response', response)
482+
})
483+
.catch(err => console.log(`Error on 'confirm-clear-history': ${err}`));
484+
})
485+
460486
// ipcMain listener that
461487
ipcMain.on("http1-fetch-message", (event, arg) => {
462488
const { method, headers, body } = arg.options;

0 commit comments

Comments
 (0)