From efc3fe5de4a0e1ebef93a241136aafd8ad337deb Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Fri, 8 Nov 2024 12:58:28 +0800 Subject: [PATCH] Try debug cache sizing on Safari --- src/locales/en.po | 36 ++++++++++++++++++------------------ src/pages/settings.jsx | 17 +++++++++++------ 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/src/locales/en.po b/src/locales/en.po index a114bef3..f32729e4 100644 --- a/src/locales/en.po +++ b/src/locales/en.po @@ -193,7 +193,7 @@ msgstr "" #: src/pages/catchup.jsx:72 #: src/pages/catchup.jsx:1447 #: src/pages/catchup.jsx:2068 -#: src/pages/settings.jsx:1140 +#: src/pages/settings.jsx:1145 msgid "Boosts" msgstr "" @@ -1270,7 +1270,7 @@ msgstr "" #: src/pages/home.jsx:224 #: src/pages/mentions.jsx:20 #: src/pages/mentions.jsx:167 -#: src/pages/settings.jsx:1132 +#: src/pages/settings.jsx:1137 #: src/pages/trending.jsx:381 msgid "Mentions" msgstr "" @@ -1325,7 +1325,7 @@ msgstr "" #: src/pages/catchup.jsx:2062 #: src/pages/favourites.jsx:11 #: src/pages/favourites.jsx:23 -#: src/pages/settings.jsx:1136 +#: src/pages/settings.jsx:1141 msgid "Likes" msgstr "" @@ -2317,7 +2317,7 @@ msgid "<0/> <1/> boosted" msgstr "" #: src/components/timeline.jsx:453 -#: src/pages/settings.jsx:1160 +#: src/pages/settings.jsx:1165 msgid "New posts" msgstr "" @@ -3169,7 +3169,7 @@ msgid "{0, plural, one {Announcement} other {Announcements}}" msgstr "" #: src/pages/notifications.jsx:614 -#: src/pages/settings.jsx:1148 +#: src/pages/settings.jsx:1153 msgid "Follow requests" msgstr "" @@ -3524,56 +3524,56 @@ msgstr "" msgid "Unable to copy version string" msgstr "" -#: src/pages/settings.jsx:1045 #: src/pages/settings.jsx:1050 +#: src/pages/settings.jsx:1055 msgid "Failed to update subscription. Please try again." msgstr "" -#: src/pages/settings.jsx:1056 +#: src/pages/settings.jsx:1061 msgid "Failed to remove subscription. Please try again." msgstr "" -#: src/pages/settings.jsx:1063 +#: src/pages/settings.jsx:1068 msgid "Push Notifications (beta)" msgstr "" -#: src/pages/settings.jsx:1085 +#: src/pages/settings.jsx:1090 msgid "Push notifications are blocked. Please enable them in your browser settings." msgstr "" -#: src/pages/settings.jsx:1094 +#: src/pages/settings.jsx:1099 msgid "Allow from <0>{0}" msgstr "" -#: src/pages/settings.jsx:1103 +#: src/pages/settings.jsx:1108 msgid "anyone" msgstr "" -#: src/pages/settings.jsx:1107 +#: src/pages/settings.jsx:1112 msgid "people I follow" msgstr "" -#: src/pages/settings.jsx:1111 +#: src/pages/settings.jsx:1116 msgid "followers" msgstr "" -#: src/pages/settings.jsx:1144 +#: src/pages/settings.jsx:1149 msgid "Follows" msgstr "" -#: src/pages/settings.jsx:1152 +#: src/pages/settings.jsx:1157 msgid "Polls" msgstr "" -#: src/pages/settings.jsx:1156 +#: src/pages/settings.jsx:1161 msgid "Post edits" msgstr "" -#: src/pages/settings.jsx:1177 +#: src/pages/settings.jsx:1182 msgid "Push permission was not granted since your last login. You'll need to <0><1>log in again to grant push permission." msgstr "" -#: src/pages/settings.jsx:1193 +#: src/pages/settings.jsx:1198 msgid "NOTE: Push notifications only work for <0>one account." msgstr "" diff --git a/src/pages/settings.jsx b/src/pages/settings.jsx index 80b53422..76773afc 100644 --- a/src/pages/settings.jsx +++ b/src/pages/settings.jsx @@ -913,22 +913,27 @@ async function getCachesKeys() { async function getCachesSize() { const keys = await caches.keys(); let total = {}; - let totalSize = 0; + let TOTAL = 0; for (const key of keys) { const cache = await caches.open(key); const k = await cache.keys(); for (const item of k) { - const response = await cache.match(item); - const blob = await response.blob(); - total[key] = (total[key] || 0) + blob.size; - totalSize += blob.size; + try { + const response = await cache.match(item); + const blob = await response.blob(); + total[key] = (total[key] || 0) + blob.size; + TOTAL += blob.size; + } catch (e) { + alert('Failed to get cache size for ' + item); + alert(e); + } } } return { ...Object.fromEntries( Object.entries(total).map(([k, v]) => [k, prettyBytes(v)]), ), - totalSize: prettyBytes(totalSize), + TOTAL: prettyBytes(TOTAL), }; }