From 4ee5a8f07d25639400a5e45c19476dc31be4d2ec Mon Sep 17 00:00:00 2001 From: Tom Beckenham <34339192+tombeckenham@users.noreply.github.com> Date: Fri, 20 Dec 2024 10:23:13 +1100 Subject: [PATCH] [FIX] Add missing storage warning messages and enhance error handling - Added new message entries for "Insufficient Storage" and "Almost run out of account storage" in English, Japanese, Russian, and Chinese locales. - Updated the `WarningStorageLowSnackbar` component to use the new "Almost run out of account storage" message. - Enhanced error handling in the `NewsService` class to prevent the news list from being emptied due to evaluation errors. Closes #316 --- _raw/_locales/en/messages.json | 3 +++ _raw/_locales/ja/messages.json | 3 +++ _raw/_locales/ru/messages.json | 3 +++ _raw/_locales/zh_CN/messages.json | 3 +++ src/background/service/news.ts | 10 ++++++++-- src/messages.json | 3 +++ src/ui/FRWComponent/WarningStorageLowSnackbar.tsx | 2 +- 7 files changed, 24 insertions(+), 3 deletions(-) diff --git a/_raw/_locales/en/messages.json b/_raw/_locales/en/messages.json index 9261fc8d..87b3436d 100644 --- a/_raw/_locales/en/messages.json +++ b/_raw/_locales/en/messages.json @@ -1316,6 +1316,9 @@ "message": "Import Profile" }, "Insufficient_Storage": { + "message": "Insufficient storage." + }, + "Almost_run_out_of_account_storage": { "message": "Almost run out of account storage." }, "Insufficient_storage_after_action": { diff --git a/_raw/_locales/ja/messages.json b/_raw/_locales/ja/messages.json index 79092f49..4e8add82 100644 --- a/_raw/_locales/ja/messages.json +++ b/_raw/_locales/ja/messages.json @@ -1316,6 +1316,9 @@ "message": "プロファイルをインポート" }, "Insufficient_Storage": { + "message": "ストレージが不足しています" + }, + "Almost_run_out_of_account_storage": { "message": "アカウントのストレージが不足しています" }, "Transaction_failed_storage_exceeded": { diff --git a/_raw/_locales/ru/messages.json b/_raw/_locales/ru/messages.json index aac00a9b..4f2505c6 100644 --- a/_raw/_locales/ru/messages.json +++ b/_raw/_locales/ru/messages.json @@ -1316,6 +1316,9 @@ "message": "Импортировать профиль" }, "Insufficient_Storage": { + "message": "Недостаточно памяти" + }, + "Almost_run_out_of_account_storage": { "message": "В вашем аккаунте недостаточно места для хранения данных" }, "Transaction_failed_storage_exceeded": { diff --git a/_raw/_locales/zh_CN/messages.json b/_raw/_locales/zh_CN/messages.json index bf3cdbe4..3afa0cd5 100644 --- a/_raw/_locales/zh_CN/messages.json +++ b/_raw/_locales/zh_CN/messages.json @@ -1316,6 +1316,9 @@ "message": "导入账户" }, "Insufficient_Storage": { + "message": "存储不足" + }, + "Almost_run_out_of_account_storage": { "message": "帐户存储空间几乎耗尽" }, "Transaction_failed_storage_exceeded": { diff --git a/src/background/service/news.ts b/src/background/service/news.ts index 9db32fba..9b53a7ce 100644 --- a/src/background/service/news.ts +++ b/src/background/service/news.ts @@ -40,8 +40,14 @@ class NewsService { const filteredNewsPromises = news .filter((n) => !this.isDismissed(n.id)) .map(async (newsItem) => { - const shouldShow = await conditionsEvaluator.evaluateConditions(newsItem.conditions); - return shouldShow ? newsItem : null; + try { + const shouldShow = await conditionsEvaluator.evaluateConditions(newsItem.conditions); + return shouldShow ? newsItem : null; + } catch (error) { + // Catch error here otherwise the whole news list will be empty + console.error('Error evaluating conditions', error); + return null; + } }); const filteredNews = await Promise.all(filteredNewsPromises) .catch((error) => { diff --git a/src/messages.json b/src/messages.json index 6ce504a1..0c2fa891 100644 --- a/src/messages.json +++ b/src/messages.json @@ -1289,6 +1289,9 @@ "message": "Import Profile" }, "Insufficient_Storage": { + "message": "Insufficient storage." + }, + "Almost_run_out_of_account_storage": { "message": "Almost run out of account storage." }, "Transaction_failed_storage_exceeded": { diff --git a/src/ui/FRWComponent/WarningStorageLowSnackbar.tsx b/src/ui/FRWComponent/WarningStorageLowSnackbar.tsx index eb7bc96c..eb1aadc7 100644 --- a/src/ui/FRWComponent/WarningStorageLowSnackbar.tsx +++ b/src/ui/FRWComponent/WarningStorageLowSnackbar.tsx @@ -13,7 +13,7 @@ export const WarningStorageLowSnackbar = ({ isLowStorageAfterAction, }: WarningStorageLowSnackbarProps = {}) => { const message = isLowStorage - ? chrome.i18n.getMessage('Insufficient_storage') + ? chrome.i18n.getMessage('Almost_run_out_of_account_storage') : isLowStorageAfterAction ? chrome.i18n.getMessage('Insufficient_storage_after_action') : undefined;