From efb42ca91144f815978bb43a7ab46a477a2a6850 Mon Sep 17 00:00:00 2001 From: Lim Chee Aun Date: Tue, 17 Sep 2024 17:17:43 +0800 Subject: [PATCH] Investigate SW cache keys --- src/locales/en.po | 38 +++++++++++++-------------- src/pages/settings.jsx | 58 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 19 deletions(-) diff --git a/src/locales/en.po b/src/locales/en.po index f7b0b492e..5c9482f37 100644 --- a/src/locales/en.po +++ b/src/locales/en.po @@ -194,7 +194,7 @@ msgstr "" #: src/pages/catchup.jsx:72 #: src/pages/catchup.jsx:1447 #: src/pages/catchup.jsx:2068 -#: src/pages/settings.jsx:1045 +#: src/pages/settings.jsx:1103 msgid "Boosts" msgstr "" @@ -1251,7 +1251,7 @@ msgstr "" #: src/pages/home.jsx:224 #: src/pages/mentions.jsx:20 #: src/pages/mentions.jsx:167 -#: src/pages/settings.jsx:1037 +#: src/pages/settings.jsx:1095 #: src/pages/trending.jsx:381 msgid "Mentions" msgstr "" @@ -1306,7 +1306,7 @@ msgstr "" #: src/pages/catchup.jsx:2062 #: src/pages/favourites.jsx:11 #: src/pages/favourites.jsx:23 -#: src/pages/settings.jsx:1041 +#: src/pages/settings.jsx:1099 msgid "Likes" msgstr "" @@ -2298,7 +2298,7 @@ msgid "<0/> <1/> boosted" msgstr "" #: src/components/timeline.jsx:453 -#: src/pages/settings.jsx:1065 +#: src/pages/settings.jsx:1123 msgid "New posts" msgstr "" @@ -3137,7 +3137,7 @@ msgid "{0, plural, one {Announcement} other {Announcements}}" msgstr "" #: src/pages/notifications.jsx:599 -#: src/pages/settings.jsx:1053 +#: src/pages/settings.jsx:1111 msgid "Follow requests" msgstr "" @@ -3492,56 +3492,56 @@ msgstr "" msgid "Unable to copy version string" msgstr "" -#: src/pages/settings.jsx:950 -#: src/pages/settings.jsx:955 +#: src/pages/settings.jsx:1008 +#: src/pages/settings.jsx:1013 msgid "Failed to update subscription. Please try again." msgstr "" -#: src/pages/settings.jsx:961 +#: src/pages/settings.jsx:1019 msgid "Failed to remove subscription. Please try again." msgstr "" -#: src/pages/settings.jsx:968 +#: src/pages/settings.jsx:1026 msgid "Push Notifications (beta)" msgstr "" -#: src/pages/settings.jsx:990 +#: src/pages/settings.jsx:1048 msgid "Push notifications are blocked. Please enable them in your browser settings." msgstr "" -#: src/pages/settings.jsx:999 +#: src/pages/settings.jsx:1057 msgid "Allow from <0>{0}" msgstr "" -#: src/pages/settings.jsx:1008 +#: src/pages/settings.jsx:1066 msgid "anyone" msgstr "" -#: src/pages/settings.jsx:1012 +#: src/pages/settings.jsx:1070 msgid "people I follow" msgstr "" -#: src/pages/settings.jsx:1016 +#: src/pages/settings.jsx:1074 msgid "followers" msgstr "" -#: src/pages/settings.jsx:1049 +#: src/pages/settings.jsx:1107 msgid "Follows" msgstr "" -#: src/pages/settings.jsx:1057 +#: src/pages/settings.jsx:1115 msgid "Polls" msgstr "" -#: src/pages/settings.jsx:1061 +#: src/pages/settings.jsx:1119 msgid "Post edits" msgstr "" -#: src/pages/settings.jsx:1082 +#: src/pages/settings.jsx:1140 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:1098 +#: src/pages/settings.jsx:1156 msgid "NOTE: Push notifications only work for <0>one account." msgstr "" diff --git a/src/pages/settings.jsx b/src/pages/settings.jsx index 1844ddc60..292ebdc57 100644 --- a/src/pages/settings.jsx +++ b/src/pages/settings.jsx @@ -841,6 +841,42 @@ function Settings({ onClose }) { )} )} +

Service Worker Cache

+ {' '} + {' '} + )} @@ -848,6 +884,28 @@ function Settings({ onClose }) { ); } +async function getCachesKeys() { + const keys = await caches.keys(); + const total = {}; + for (const key of keys) { + const cache = await caches.open(key); + const k = await cache.keys(); + total[key] = k.length; + } + return total; +} + +function clearCacheKey(key) { + return caches.delete(key); +} + +async function clearCaches() { + const keys = await caches.keys(); + for (const key of keys) { + await caches.delete(key); + } +} + function PushNotificationsSection({ onClose }) { if (!isPushSupported()) return null;