From 640ed6818aaaf6aa28cb48e261f8ee81c24abb70 Mon Sep 17 00:00:00 2001 From: Svallinn <41585298+Svallinn@users.noreply.github.com> Date: Mon, 10 May 2021 06:01:35 +0100 Subject: [PATCH] Main: Clear cache and storage data only when the last window is closed This prevents the CONSENT cookie from being deleted after a window is closed by the user, making it so that the user can no longer load the comment section. --- src/main/index.js | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/main/index.js b/src/main/index.js index 5697df66..754cdf76 100644 --- a/src/main/index.js +++ b/src/main/index.js @@ -327,19 +327,22 @@ function runApp() { }) newWindow.on('close', () => { - newWindow.webContents.session.clearCache() - newWindow.webContents.session.clearStorageData({ - storages: [ - 'appcache', - 'cookies', - 'filesystem', - 'indexdb', - 'shadercache', - 'websql', - 'serviceworkers', - 'cachestorage' - ] - }) + // Clear cache and storage if it's the last window + if (openedWindows.length === 1) { + newWindow.webContents.session.clearCache() + newWindow.webContents.session.clearStorageData({ + storages: [ + 'appcache', + 'cookies', + 'filesystem', + 'indexdb', + 'shadercache', + 'websql', + 'serviceworkers', + 'cachestorage' + ] + }) + } }) newWindow.on('closed', () => {