From 614b428570a8bb5a964a92ae733e2b50e4d8bf51 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Sat, 7 Nov 2020 09:58:46 -0500 Subject: Fix byte count labels (#998) * Add 'TB' label * Prevent overflow * Fix storage information on the old settings page --- ext/bg/js/settings/storage-controller.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'ext/bg/js') diff --git a/ext/bg/js/settings/storage-controller.js b/ext/bg/js/settings/storage-controller.js index bc57017f..32b98304 100644 --- a/ext/bg/js/settings/storage-controller.js +++ b/ext/bg/js/settings/storage-controller.js @@ -148,9 +148,10 @@ class StorageController { _bytesToLabeledString(size) { const base = 1000; - const labels = [' bytes', 'KB', 'MB', 'GB']; + const labels = [' bytes', 'KB', 'MB', 'GB', 'TB']; + const maxLabelIndex = labels.length - 1; let labelIndex = 0; - while (size >= base) { + while (size >= base && labelIndex < maxLabelIndex) { size /= base; ++labelIndex; } -- cgit v1.2.3