Skip to content

Commit

Permalink
[FIX] Add missing storage warning messages and enhance error handling
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
tombeckenham committed Dec 19, 2024
1 parent bffed50 commit 4ee5a8f
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 3 deletions.
3 changes: 3 additions & 0 deletions _raw/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
3 changes: 3 additions & 0 deletions _raw/_locales/ja/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,9 @@
"message": "プロファイルをインポート"
},
"Insufficient_Storage": {
"message": "ストレージが不足しています"
},
"Almost_run_out_of_account_storage": {
"message": "アカウントのストレージが不足しています"
},
"Transaction_failed_storage_exceeded": {
Expand Down
3 changes: 3 additions & 0 deletions _raw/_locales/ru/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,9 @@
"message": "Импортировать профиль"
},
"Insufficient_Storage": {
"message": "Недостаточно памяти"
},
"Almost_run_out_of_account_storage": {
"message": "В вашем аккаунте недостаточно места для хранения данных"
},
"Transaction_failed_storage_exceeded": {
Expand Down
3 changes: 3 additions & 0 deletions _raw/_locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1316,6 +1316,9 @@
"message": "导入账户"
},
"Insufficient_Storage": {
"message": "存储不足"
},
"Almost_run_out_of_account_storage": {
"message": "帐户存储空间几乎耗尽"
},
"Transaction_failed_storage_exceeded": {
Expand Down
10 changes: 8 additions & 2 deletions src/background/service/news.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
3 changes: 3 additions & 0 deletions src/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/FRWComponent/WarningStorageLowSnackbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 4ee5a8f

Please sign in to comment.