From 57672ad384f9d2690f82e9c2c7d6cd85be76daa1 Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 4 Oct 2019 12:17:01 +0100 Subject: [PATCH] Request persistent storage on Electron It's still not 100% clear whether storage is always persistent on Electron, but we seem to be getting reports of it being deleted in the wild on Electron, so let's try calling the API to request persistent storage. It won't pop up a dialog on Electron. In the worst case it will give us some logging so we know what the API calls return. We could do this on non-desktop too but it's a bit of a mess because Firefox prompts the user but Chrome makes a decision itself based on how much the user visits the site. --- src/vector/platform/ElectronPlatform.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/vector/platform/ElectronPlatform.js b/src/vector/platform/ElectronPlatform.js index 8700ae249b..8b01f86417 100644 --- a/src/vector/platform/ElectronPlatform.js +++ b/src/vector/platform/ElectronPlatform.js @@ -100,6 +100,16 @@ export default class ElectronPlatform extends VectorBasePlatform { this.startUpdateCheck = this.startUpdateCheck.bind(this); this.stopUpdateCheck = this.stopUpdateCheck.bind(this); + + this._tryPersistStorage(); + } + + async _tryPersistStorage() { + if (navigator.storage && navigator.storage.persist) { + const granted = await navigator.storage.persist(); + const persisted = await navigator.storage.persisted(); + console.log("Storage persist request granted: " + granted + " persisted: " + persisted); + } } async getConfig(): Promise<{}> {