diff --git a/src/components/PresetOnline.tsx b/src/components/PresetOnline.tsx index bc725dd..db59157 100644 --- a/src/components/PresetOnline.tsx +++ b/src/components/PresetOnline.tsx @@ -24,6 +24,17 @@ function PresetOnline() { return ; })} + ) : presetsOnlineContext.error && !presetsOnlineContext.loading ? ( + + {getTranslation("PresetOnline.pleaseCheckInternetConnection", "Please check your internet connection.")} +
+ +
) : presetsOnlineContext.loading || !sysInfoContext?.signature ? (
diff --git a/src/contexts/PresetsOnline.tsx b/src/contexts/PresetsOnline.tsx index 0bfd035..fc0dae5 100644 --- a/src/contexts/PresetsOnline.tsx +++ b/src/contexts/PresetsOnline.tsx @@ -1,6 +1,7 @@ import { createContext } from "react"; let context: PresetsOnlineContextType = { + error: false, loading: true, list: [], update() {}, diff --git a/src/locales/ch.json b/src/locales/ch.json index 6c89b70..da9c55d 100644 --- a/src/locales/ch.json +++ b/src/locales/ch.json @@ -99,5 +99,8 @@ "ryzenAdjBottomBar.createPreset": "新增预设", "ryzenAdjBottomBar.reset": "重置", "app.localeSelectorModalTitle": "更改语言", - "appContext.newReleaseAvailable": "有新版本发布,请检查发布标签。" + "appContext.newReleaseAvailable": "有新版本发布,请检查发布标签。", + "PresetOnline.errorLoadingPresets": "无法加载预设。", + "PresetOnline.retryLoadingPresetListBtn": "重试", + "PresetOnline.pleaseCheckInternetConnection": "请检查您的互联网连接。" } diff --git a/src/locales/de.json b/src/locales/de.json index fada2ef..f085229 100644 --- a/src/locales/de.json +++ b/src/locales/de.json @@ -99,5 +99,8 @@ "ryzenAdjBottomBar.createPreset": "Preset erstellen", "ryzenAdjBottomBar.reset": "Zurücksetzen", "app.localeSelectorModalTitle": "Sprache ändern", - "appContext.newReleaseAvailable": "Eine neue Version ist verfügbar. Überprüfen Sie die Registerkarte Version." + "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." } diff --git a/src/locales/en.json b/src/locales/en.json index 44cf2d4..ebc2880 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -99,5 +99,8 @@ "ryzenAdjBottomBar.createPreset": "Create preset", "ryzenAdjBottomBar.reset": "Reset", "app.localeSelectorModalTitle": "Change language", - "appContext.newReleaseAvailable": "A new release is available, please check the release tab." + "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." } diff --git a/src/locales/fr.json b/src/locales/fr.json index a66cf9c..ea5b566 100644 --- a/src/locales/fr.json +++ b/src/locales/fr.json @@ -99,5 +99,8 @@ "ryzenAdjBottomBar.reset": "Reset", "ryzenAdjBottomBar.createPreset": "Créer preset", "app.localeSelectorModalTitle": "Changer de langage", - "appContext.newReleaseAvailable": "Une nouvelle version est disponible, vérifiez l'onglet releases." + "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." } diff --git a/src/locales/tr.json b/src/locales/tr.json index 7438e39..7376c65 100644 --- a/src/locales/tr.json +++ b/src/locales/tr.json @@ -99,5 +99,8 @@ "ryzenAdjBottomBar.createPreset": "Preset oluştur", "ryzenAdjBottomBar.reset": "Sıfırla", "app.localeSelectorModalTitle": "Dil değiştir", - "appContext.newReleaseAvailable": "Yeni bir sürüm mevcut, lütfen sürüm sekmesini kontrol edin." + "appContext.newReleaseAvailable": "Yeni bir sürüm mevcut, lütfen sürüm sekmesini kontrol edin.", + "PresetOnline.errorLoadingPresets": "Ön ayarlar yüklenemiyor.", + "PresetOnline.retryLoadingPresetListBtn": "Yeniden Dene", + "PresetOnline.pleaseCheckInternetConnection": "Lütfen internet bağlantınızı kontrol edin." } diff --git a/src/react-app-env.d.ts b/src/react-app-env.d.ts index ef558a1..f22a196 100644 --- a/src/react-app-env.d.ts +++ b/src/react-app-env.d.ts @@ -114,6 +114,7 @@ type ApiPreset = { }; type PresetsOnlineContextType = { + error: boolean; loading: boolean; list: Array; update(): void; diff --git a/src/scenes/PresetsScene.tsx b/src/scenes/PresetsScene.tsx index 6e21ecf..6ca2e50 100644 --- a/src/scenes/PresetsScene.tsx +++ b/src/scenes/PresetsScene.tsx @@ -13,6 +13,7 @@ const uikit = window.require("uikit"); class PresetsScene extends React.Component<{}, PresetsOnlineContextType> { _isMounted = false; state: PresetsOnlineContextType = { + error: false, loading: false, list: [], update: this.updatePresetList.bind(this), @@ -72,7 +73,10 @@ class PresetsScene extends React.Component<{}, PresetsOnlineContextType> { fetch(process.env.REACT_APP_SERVER_ENDPOINT + "/presets", requestOption) .then(response => response.json()) .then((data: Array) => { - if (this._isMounted) this.setState({ list: data, loading: false }); + if (this._isMounted) this.setState({ list: data, loading: false, error: false }); + }) + .catch(reason => { + if (this._isMounted) this.setState({ error: true, loading: false }); }); }