diff options
author | 2021-09-08 19:49:12 +0530 | |
---|---|---|
committer | 2021-09-08 19:49:12 +0530 | |
commit | 1fab031b14f02037193e1b40dc92f3cf3d2d5c04 (patch) | |
tree | 2008a9165e3b651b959daff4308fe555b49a1166 /src/webview/sessionHandler.ts | |
parent | New translations en-US.json (#1886) (diff) | |
download | ferdium-app-1fab031b14f02037193e1b40dc92f3cf3d2d5c04.tar.gz ferdium-app-1fab031b14f02037193e1b40dc92f3cf3d2d5c04.tar.zst ferdium-app-1fab031b14f02037193e1b40dc92f3cf3d2d5c04.zip |
refactor: expose some more methods for session handling on the main repo (#1887)
Diffstat (limited to 'src/webview/sessionHandler.ts')
-rw-r--r-- | src/webview/sessionHandler.ts | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/webview/sessionHandler.ts b/src/webview/sessionHandler.ts new file mode 100644 index 000000000..6a7e62ac5 --- /dev/null +++ b/src/webview/sessionHandler.ts | |||
@@ -0,0 +1,28 @@ | |||
1 | import { getCurrentWebContents } from '@electron/remote'; | ||
2 | |||
3 | const debug = require('debug')('Ferdi:Plugin:SessionHandler'); | ||
4 | |||
5 | export class SessionHandler { | ||
6 | clearStorageData(storageLocations: string[]) { | ||
7 | try { | ||
8 | debug('Clearing storageLocations:', storageLocations); | ||
9 | const { session } = getCurrentWebContents(); | ||
10 | session.flushStorageData(); | ||
11 | session.clearStorageData({ storages: storageLocations }); | ||
12 | } catch (err) { | ||
13 | debug(err); | ||
14 | } | ||
15 | } | ||
16 | |||
17 | async releaseServiceWorkers() { | ||
18 | try { | ||
19 | const registrations = await window.navigator.serviceWorker.getRegistrations(); | ||
20 | registrations.forEach(r => { | ||
21 | r.unregister(); | ||
22 | debug('ServiceWorker unregistered'); | ||
23 | }); | ||
24 | } catch (err) { | ||
25 | debug(err); | ||
26 | } | ||
27 | } | ||
28 | } | ||