summaryrefslogtreecommitdiff
path: root/ext/bg/js/settings/storage-controller.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-10-10 17:37:16 -0400
committerGitHub <noreply@github.com>2020-10-10 17:37:16 -0400
commit0244d07ea9afc0a7893c1ba448ec284e95a55073 (patch)
tree278309e184ee1d2b047d6457997d376f8ffdcb0f /ext/bg/js/settings/storage-controller.js
parent19e0346484a4481f8adbf0e3ad51220458767a56 (diff)
Storage controller refactor (#907)
* Use array for use/quota nodes * Use classes instead of ids
Diffstat (limited to 'ext/bg/js/settings/storage-controller.js')
-rw-r--r--ext/bg/js/settings/storage-controller.js20
1 files changed, 12 insertions, 8 deletions
diff --git a/ext/bg/js/settings/storage-controller.js b/ext/bg/js/settings/storage-controller.js
index 72d5a606..bc57017f 100644
--- a/ext/bg/js/settings/storage-controller.js
+++ b/ext/bg/js/settings/storage-controller.js
@@ -31,12 +31,12 @@ class StorageController {
prepare() {
this._persistentStorageCheckbox = document.querySelector('#storage-persistent-checkbox');
- this._storageUsageNode = document.querySelector('#storage-usage');
- this._storageQuotaNode = document.querySelector('#storage-quota');
- this._storageUseFiniteNodes = document.querySelectorAll('#storage-use-finite');
- this._storageUseInfiniteNodes = document.querySelectorAll('#storage-use-infinite');
- this._storageUseValidNodes = document.querySelectorAll('#storage-use-valid');
- this._storageUseInvalidNodes = document.querySelectorAll('#storage-use-invalid');
+ this._storageUsageNodes = document.querySelectorAll('.storage-usage');
+ this._storageQuotaNodes = document.querySelectorAll('.storage-quota');
+ this._storageUseFiniteNodes = document.querySelectorAll('.storage-use-finite');
+ this._storageUseInfiniteNodes = document.querySelectorAll('.storage-use-infinite');
+ this._storageUseValidNodes = document.querySelectorAll('.storage-use-valid');
+ this._storageUseInvalidNodes = document.querySelectorAll('.storage-use-invalid');
this._preparePersistentStorage();
this.updateStats();
@@ -56,8 +56,12 @@ class StorageController {
// Firefox reports usage as 0 when persistent storage is enabled.
const finite = valid && (estimate.usage > 0 || !(await this._isStoragePeristent()));
if (finite) {
- this._storageUsageNode.textContent = this._bytesToLabeledString(estimate.usage);
- this._storageQuotaNode.textContent = this._bytesToLabeledString(estimate.quota);
+ for (const node of this._storageUsageNodes) {
+ node.textContent = this._bytesToLabeledString(estimate.usage);
+ }
+ for (const node of this._storageQuotaNodes) {
+ node.textContent = this._bytesToLabeledString(estimate.quota);
+ }
}
this._setElementsVisible(this._storageUseFiniteNodes, valid && finite);