aboutsummaryrefslogtreecommitdiff
path: root/ext/bg/js/settings.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/bg/js/settings.js')
-rw-r--r--ext/bg/js/settings.js32
1 files changed, 30 insertions, 2 deletions
diff --git a/ext/bg/js/settings.js b/ext/bg/js/settings.js
index 84b54ba9..7ad628ba 100644
--- a/ext/bg/js/settings.js
+++ b/ext/bg/js/settings.js
@@ -724,14 +724,13 @@ async function storageEstimate() {
storageEstimate.mostRecent = null;
async function storageInfoInitialize() {
+ storagePersistInitialize();
const browser = await getBrowser();
const container = document.querySelector('#storage-info');
container.setAttribute('data-browser', browser);
await storageShowInfo();
- container.classList.remove('storage-hidden');
-
document.querySelector('#storage-refresh').addEventListener('click', () => storageShowInfo(), false);
}
@@ -770,6 +769,35 @@ function storageSpinnerShow(show) {
}
}
+async function storagePersistInitialize() {
+ if (!(navigator.storage && navigator.storage.persist)) {
+ // Not supported
+ return;
+ }
+
+ const info = document.querySelector('#storage-persist-info');
+ const button = document.querySelector('#storage-persist-button');
+ const checkbox = document.querySelector('#storage-persist-button-checkbox');
+
+ info.classList.remove('storage-hidden');
+ button.classList.remove('storage-hidden');
+
+ let persisted = await navigator.storage.persisted();
+ if (persisted) {
+ checkbox.checked = true;
+ }
+
+ button.addEventListener('click', async () => {
+ if (persisted) {
+ return;
+ }
+ if (await navigator.storage.persist()) {
+ persisted = true;
+ checkbox.checked = true;
+ }
+ }, false);
+}
+
/*
* Information