From f6e9c32c48081be68a6b9bbf5ff3b86a0d56704a Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Wed, 25 Mar 2020 12:04:09 +0100 Subject: [PATCH 1/3] fall back to non-standard persisted api for Safari --- src/rageshake/submit-rageshake.js | 6 ++++++ src/utils/StorageManager.js | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/src/rageshake/submit-rageshake.js b/src/rageshake/submit-rageshake.js index 53e9f24788..5a7039a913 100644 --- a/src/rageshake/submit-rageshake.js +++ b/src/rageshake/submit-rageshake.js @@ -119,6 +119,12 @@ export default async function sendBugReport(bugReportEndpoint, opts) { body.append("storageManager_persisted", await navigator.storage.persisted()); } catch (e) {} } + // Safari + if (document.hasStorageAccess) { + try { + body.append("storageManager_persisted", await document.hasStorageAccess()); + } catch (e) {} + } if (navigator.storage && navigator.storage.estimate) { try { const estimate = await navigator.storage.estimate(); diff --git a/src/utils/StorageManager.js b/src/utils/StorageManager.js index 4ed118da8a..175772903d 100644 --- a/src/utils/StorageManager.js +++ b/src/utils/StorageManager.js @@ -48,6 +48,11 @@ export function tryPersistStorage() { navigator.storage.persist().then(persistent => { console.log("StorageManager: Persistent?", persistent); }); + } else if (document.requestStorageAccess) { //Safari + document.requestStorageAccess().then( + () => console.log("StorageManager: Persistent?", true), + () => console.log("StorageManager: Persistent?", false), + ); } else { console.log("StorageManager: Persistence unsupported"); } From 9a5f4d9b22b2dadaddcdca3e0e17acbd969bc9dd Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Wed, 25 Mar 2020 12:07:11 +0100 Subject: [PATCH 2/3] fall back, don't do both on FF --- src/rageshake/submit-rageshake.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/rageshake/submit-rageshake.js b/src/rageshake/submit-rageshake.js index 5a7039a913..00ef87f89c 100644 --- a/src/rageshake/submit-rageshake.js +++ b/src/rageshake/submit-rageshake.js @@ -118,9 +118,7 @@ export default async function sendBugReport(bugReportEndpoint, opts) { try { body.append("storageManager_persisted", await navigator.storage.persisted()); } catch (e) {} - } - // Safari - if (document.hasStorageAccess) { + } else if (document.hasStorageAccess) { // Safari try { body.append("storageManager_persisted", await document.hasStorageAccess()); } catch (e) {} From 0097134ade4c3953d57fa64e33c70d3b45d92c5f Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Wed, 25 Mar 2020 17:56:35 +0000 Subject: [PATCH 3/3] Update src/utils/StorageManager.js Co-Authored-By: J. Ryan Stinnett --- src/utils/StorageManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/StorageManager.js b/src/utils/StorageManager.js index 175772903d..e29b6d9b0e 100644 --- a/src/utils/StorageManager.js +++ b/src/utils/StorageManager.js @@ -48,7 +48,7 @@ export function tryPersistStorage() { navigator.storage.persist().then(persistent => { console.log("StorageManager: Persistent?", persistent); }); - } else if (document.requestStorageAccess) { //Safari + } else if (document.requestStorageAccess) { // Safari document.requestStorageAccess().then( () => console.log("StorageManager: Persistent?", true), () => console.log("StorageManager: Persistent?", false),