From adf71558005856c99f4be7fa19694abd63c8ab79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Quentin=20=E2=80=9CStorm1er=E2=80=9D=20Decaunes?= Date: Mon, 16 Mar 2020 15:58:23 +0100 Subject: [PATCH] fix: Avoid crash when an error exist in upload preset request response. --- src/components/PresetButtons.tsx | 5 +++++ src/locales/ch.json | 3 ++- src/locales/de.json | 3 ++- src/locales/en.json | 3 ++- src/locales/fr.json | 3 ++- src/locales/tr.json | 3 ++- src/scenes/PresetsScene.tsx | 2 +- 7 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/components/PresetButtons.tsx b/src/components/PresetButtons.tsx index 4d65f5f..12b0596 100644 --- a/src/components/PresetButtons.tsx +++ b/src/components/PresetButtons.tsx @@ -119,6 +119,11 @@ class PresetButtons extends React.Component { }) ); presetsOnlineContext.update(); + }) + .catch(() => { + NotificationContext.error( + getTranslation("presetButtons.uploadError", "An error occured while uploading the preset") + ); }); }); }; diff --git a/src/locales/ch.json b/src/locales/ch.json index 41329b1..a2bb43d 100644 --- a/src/locales/ch.json +++ b/src/locales/ch.json @@ -104,5 +104,6 @@ "appContext.newReleaseAvailable": "有新版本发布,请检查发布标签。", "PresetOnline.errorLoadingPresets": "无法加载预设。", "PresetOnline.retryLoadingPresetListBtn": "重试", - "PresetOnline.pleaseCheckInternetConnection": "请检查您的互联网连接。" + "PresetOnline.pleaseCheckInternetConnection": "请检查您的互联网连接。", + "presetButtons.uploadError": "上载预设时发生错误" } diff --git a/src/locales/de.json b/src/locales/de.json index ef5a1ab..7c198a5 100644 --- a/src/locales/de.json +++ b/src/locales/de.json @@ -104,5 +104,6 @@ "appContext.newReleaseAvailable": "Eine neue Version ist verfügbar. Überprüfen Sie die Registerkarte Version.", "PresetOnline.errorLoadingPresets": "Presets können nicht geladen werden.", "PresetOnline.retryLoadingPresetListBtn": "Wiederholen", - "PresetOnline.pleaseCheckInternetConnection": "Bitte überprüfe deine Internetverbindung." + "PresetOnline.pleaseCheckInternetConnection": "Bitte überprüfe deine Internetverbindung.", + "presetButtons.uploadError": "Beim Hochladen der Voreinstellung ist ein Fehler aufgetreten" } diff --git a/src/locales/en.json b/src/locales/en.json index b7dd0f6..63f1096 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -104,5 +104,6 @@ "appContext.newReleaseAvailable": "A new release is available, please check the release tab.", "PresetOnline.errorLoadingPresets": "Unable to load presets.", "PresetOnline.retryLoadingPresetListBtn": "Retry", - "PresetOnline.pleaseCheckInternetConnection": "Please check your internet connection." + "PresetOnline.pleaseCheckInternetConnection": "Please check your internet connection.", + "presetButtons.uploadError": "An error occured while uploading the preset" } diff --git a/src/locales/fr.json b/src/locales/fr.json index 6dacd78..60a6c6b 100644 --- a/src/locales/fr.json +++ b/src/locales/fr.json @@ -104,5 +104,6 @@ "appContext.newReleaseAvailable": "Une nouvelle version est disponible, vérifiez l'onglet releases.", "PresetOnline.errorLoadingPresets": "Impossible de charger les presets en ligne.", "PresetOnline.retryLoadingPresetListBtn": "Réessayer", - "PresetOnline.pleaseCheckInternetConnection": "Veuillez vérifier votre connexion internet." + "PresetOnline.pleaseCheckInternetConnection": "Veuillez vérifier votre connexion internet.", + "presetButtons.uploadError": "Une erreur est survenu lors de l'upload du preset" } diff --git a/src/locales/tr.json b/src/locales/tr.json index 0790b96..f2720ee 100644 --- a/src/locales/tr.json +++ b/src/locales/tr.json @@ -104,5 +104,6 @@ "appContext.newReleaseAvailable": "Yeni bir sürüm mevcut, lütfen Sürümler sekmesini kontrol edin.", "PresetOnline.errorLoadingPresets": "Ön ayarlar yüklenemiyor.", "PresetOnline.retryLoadingPresetListBtn": "Yeniden Dene", - "PresetOnline.pleaseCheckInternetConnection": "Lütfen internet bağlantınızı kontrol edin." + "PresetOnline.pleaseCheckInternetConnection": "Lütfen internet bağlantınızı kontrol edin.", + "presetButtons.uploadError": "Ön ayar yüklenirken bir hata oluştu" } diff --git a/src/scenes/PresetsScene.tsx b/src/scenes/PresetsScene.tsx index 4a7b4ba..09a29fb 100644 --- a/src/scenes/PresetsScene.tsx +++ b/src/scenes/PresetsScene.tsx @@ -32,7 +32,7 @@ class PresetsScene extends React.Component<{}, PresetsOnlineContextType> { this.isUserAlreadyVotedForThisPreset = this.isUserAlreadyVotedForThisPreset.bind(this); } - uploadPreset(preset: ApiPreset) { + uploadPreset(preset: ApiPreset): Promise { const requestOption: RequestInit = { method: "POST", headers: {