Storage controller refactor (#907)
* Use array for use/quota nodes * Use classes instead of ids
This commit is contained in:
parent
19e0346484
commit
0244d07ea9
@ -31,12 +31,12 @@ class StorageController {
|
|||||||
|
|
||||||
prepare() {
|
prepare() {
|
||||||
this._persistentStorageCheckbox = document.querySelector('#storage-persistent-checkbox');
|
this._persistentStorageCheckbox = document.querySelector('#storage-persistent-checkbox');
|
||||||
this._storageUsageNode = document.querySelector('#storage-usage');
|
this._storageUsageNodes = document.querySelectorAll('.storage-usage');
|
||||||
this._storageQuotaNode = document.querySelector('#storage-quota');
|
this._storageQuotaNodes = document.querySelectorAll('.storage-quota');
|
||||||
this._storageUseFiniteNodes = document.querySelectorAll('#storage-use-finite');
|
this._storageUseFiniteNodes = document.querySelectorAll('.storage-use-finite');
|
||||||
this._storageUseInfiniteNodes = document.querySelectorAll('#storage-use-infinite');
|
this._storageUseInfiniteNodes = document.querySelectorAll('.storage-use-infinite');
|
||||||
this._storageUseValidNodes = document.querySelectorAll('#storage-use-valid');
|
this._storageUseValidNodes = document.querySelectorAll('.storage-use-valid');
|
||||||
this._storageUseInvalidNodes = document.querySelectorAll('#storage-use-invalid');
|
this._storageUseInvalidNodes = document.querySelectorAll('.storage-use-invalid');
|
||||||
|
|
||||||
this._preparePersistentStorage();
|
this._preparePersistentStorage();
|
||||||
this.updateStats();
|
this.updateStats();
|
||||||
@ -56,8 +56,12 @@ class StorageController {
|
|||||||
// Firefox reports usage as 0 when persistent storage is enabled.
|
// Firefox reports usage as 0 when persistent storage is enabled.
|
||||||
const finite = valid && (estimate.usage > 0 || !(await this._isStoragePeristent()));
|
const finite = valid && (estimate.usage > 0 || !(await this._isStoragePeristent()));
|
||||||
if (finite) {
|
if (finite) {
|
||||||
this._storageUsageNode.textContent = this._bytesToLabeledString(estimate.usage);
|
for (const node of this._storageUsageNodes) {
|
||||||
this._storageQuotaNode.textContent = this._bytesToLabeledString(estimate.quota);
|
node.textContent = this._bytesToLabeledString(estimate.usage);
|
||||||
|
}
|
||||||
|
for (const node of this._storageQuotaNodes) {
|
||||||
|
node.textContent = this._bytesToLabeledString(estimate.quota);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this._setElementsVisible(this._storageUseFiniteNodes, valid && finite);
|
this._setElementsVisible(this._storageUseFiniteNodes, valid && finite);
|
||||||
|
@ -805,13 +805,13 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="storage-use" hidden>
|
<div id="storage-use" hidden>
|
||||||
<p class="help-block" id="storage-use-invalid">
|
<p class="help-block" class="storage-use-invalid">
|
||||||
Yomichan is using an indeterminate amount of storage.
|
Yomichan is using an indeterminate amount of storage.
|
||||||
</p>
|
</p>
|
||||||
<p class="help-block" id="storage-use-finite" hidden>
|
<p class="help-block" class="storage-use-finite" hidden>
|
||||||
Yomichan is using approximately <strong id="storage-usage"></strong> of <strong id="storage-quota"></strong>.
|
Yomichan is using approximately <strong class="storage-usage"></strong> of <strong class="storage-quota"></strong>.
|
||||||
</p>
|
</p>
|
||||||
<p class="help-block" id="storage-use-infinite" hidden>
|
<p class="help-block" class="storage-use-infinite" hidden>
|
||||||
Yomichan is permitted <strong>unlimited storage</strong>.
|
Yomichan is permitted <strong>unlimited storage</strong>.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user