aboutsummaryrefslogtreecommitdiffstats
path: root/src/electron
diff options
context:
space:
mode:
authorLibravatar Vijay Aravamudhan <vraravam@users.noreply.github.com>2021-09-26 11:14:23 +0530
committerLibravatar GitHub <noreply@github.com>2021-09-26 11:14:23 +0530
commit35b31dd0872ed81da7f004138e40b68a4b7e6b51 (patch)
tree6cfcd87ff4f19a1338134977859e3e2d80510084 /src/electron
parentchore: tag the 'recipes' submodule when tagging the main repo - to help ident... (diff)
downloadferdium-app-35b31dd0872ed81da7f004138e40b68a4b7e6b51.tar.gz
ferdium-app-35b31dd0872ed81da7f004138e40b68a4b7e6b51.tar.zst
ferdium-app-35b31dd0872ed81da7f004138e40b68a4b7e6b51.zip
refactor: remove references to 'electron/remote' - part deux (#1987)
Diffstat (limited to 'src/electron')
-rw-r--r--src/electron/ipc-api/index.ts2
-rw-r--r--src/electron/ipc-api/sessionStorage.ts35
2 files changed, 37 insertions, 0 deletions
diff --git a/src/electron/ipc-api/index.ts b/src/electron/ipc-api/index.ts
index 06c50be10..f03f61517 100644
--- a/src/electron/ipc-api/index.ts
+++ b/src/electron/ipc-api/index.ts
@@ -1,6 +1,7 @@
1import { BrowserWindow, Tray } from 'electron'; 1import { BrowserWindow, Tray } from 'electron';
2import autoUpdate from './autoUpdate'; 2import autoUpdate from './autoUpdate';
3import settings from './settings'; 3import settings from './settings';
4import sessionStorage from './sessionStorage';
4import appIndicator from './appIndicator'; 5import appIndicator from './appIndicator';
5import download from './download'; 6import download from './download';
6import localServer from './localServer'; 7import localServer from './localServer';
@@ -14,6 +15,7 @@ export default (params: {
14 tray: Tray; 15 tray: Tray;
15}) => { 16}) => {
16 settings(params); 17 settings(params);
18 sessionStorage();
17 autoUpdate(params); 19 autoUpdate(params);
18 appIndicator(params); 20 appIndicator(params);
19 download(params); 21 download(params);
diff --git a/src/electron/ipc-api/sessionStorage.ts b/src/electron/ipc-api/sessionStorage.ts
new file mode 100644
index 000000000..3eda568a1
--- /dev/null
+++ b/src/electron/ipc-api/sessionStorage.ts
@@ -0,0 +1,35 @@
1import { ipcMain, Session, session } from 'electron';
2
3import { TODOS_PARTITION_ID } from '../../config';
4
5const debug = require('debug')('Ferdi:ipcApi:sessionStorage');
6
7function deduceSession(serviceId: string | undefined | null): Session {
8 if (serviceId) {
9 return session.fromPartition(serviceId === TODOS_PARTITION_ID ? TODOS_PARTITION_ID : `persist:service-${serviceId}`);
10 }
11 return session.defaultSession;
12}
13
14export default async () => {
15 ipcMain.on('clear-storage-data', (_event, { serviceId, targetsToClear }) => {
16 try {
17 const serviceSession = deduceSession(serviceId);
18 serviceSession.flushStorageData();
19 if (targetsToClear) {
20 debug('Clearing targets:', targetsToClear);
21 serviceSession.clearStorageData(targetsToClear);
22 } else {
23 debug('Clearing all targets');
24 serviceSession.clearStorageData();
25 }
26 } catch (error) {
27 debug(error);
28 }
29 });
30
31 ipcMain.handle('clear-cache', (_event, { serviceId }) => {
32 const serviceSession = deduceSession(serviceId);
33 return serviceSession.clearCache();
34 });
35};