fix: Display an friendly message instead of loading indefinitely online presets.

Translations update consequently, they may not be accurate as I used google translate.
This commit is contained in:
Quentin “Storm1er” Decaunes 2020-03-16 09:54:54 +01:00
parent 8fcbfc57a2
commit 605741b9c1
9 changed files with 38 additions and 6 deletions

View File

@ -24,6 +24,17 @@ function PresetOnline() {
return <PresetOnlineLine preset={preset} key={`online_${index}_${presetName}_btn`} />; return <PresetOnlineLine preset={preset} key={`online_${index}_${presetName}_btn`} />;
})} })}
</ul> </ul>
) : presetsOnlineContext.error && !presetsOnlineContext.loading ? (
<Card title={getTranslation("PresetOnline.errorLoadingPresets", "Unable to load presets.")}>
{getTranslation("PresetOnline.pleaseCheckInternetConnection", "Please check your internet connection.")}
<br />
<button
className="uk-margin-small-bottom uk-button uk-button-small uk-button-default"
onClick={() => presetsOnlineContext.update()}
>
{getTranslation("PresetOnline.retryLoadingPresetListBtn", "Retry")}
</button>
</Card>
) : presetsOnlineContext.loading || !sysInfoContext?.signature ? ( ) : presetsOnlineContext.loading || !sysInfoContext?.signature ? (
<div className="uk-flex uk-flex-center"> <div className="uk-flex uk-flex-center">
<div uk-spinner="ratio: 2"></div> <div uk-spinner="ratio: 2"></div>

View File

@ -1,6 +1,7 @@
import { createContext } from "react"; import { createContext } from "react";
let context: PresetsOnlineContextType = { let context: PresetsOnlineContextType = {
error: false,
loading: true, loading: true,
list: [], list: [],
update() {}, update() {},

View File

@ -99,5 +99,8 @@
"ryzenAdjBottomBar.createPreset": "新增预设", "ryzenAdjBottomBar.createPreset": "新增预设",
"ryzenAdjBottomBar.reset": "重置", "ryzenAdjBottomBar.reset": "重置",
"app.localeSelectorModalTitle": "更改语言", "app.localeSelectorModalTitle": "更改语言",
"appContext.newReleaseAvailable": "有新版本发布,请检查发布标签。" "appContext.newReleaseAvailable": "有新版本发布,请检查发布标签。",
"PresetOnline.errorLoadingPresets": "无法加载预设。",
"PresetOnline.retryLoadingPresetListBtn": "重试",
"PresetOnline.pleaseCheckInternetConnection": "请检查您的互联网连接。"
} }

View File

@ -99,5 +99,8 @@
"ryzenAdjBottomBar.createPreset": "Preset erstellen", "ryzenAdjBottomBar.createPreset": "Preset erstellen",
"ryzenAdjBottomBar.reset": "Zurücksetzen", "ryzenAdjBottomBar.reset": "Zurücksetzen",
"app.localeSelectorModalTitle": "Sprache ändern", "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."
} }

View File

@ -99,5 +99,8 @@
"ryzenAdjBottomBar.createPreset": "Create preset", "ryzenAdjBottomBar.createPreset": "Create preset",
"ryzenAdjBottomBar.reset": "Reset", "ryzenAdjBottomBar.reset": "Reset",
"app.localeSelectorModalTitle": "Change language", "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."
} }

View File

@ -99,5 +99,8 @@
"ryzenAdjBottomBar.reset": "Reset", "ryzenAdjBottomBar.reset": "Reset",
"ryzenAdjBottomBar.createPreset": "Créer preset", "ryzenAdjBottomBar.createPreset": "Créer preset",
"app.localeSelectorModalTitle": "Changer de langage", "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."
} }

View File

@ -99,5 +99,8 @@
"ryzenAdjBottomBar.createPreset": "Preset oluştur", "ryzenAdjBottomBar.createPreset": "Preset oluştur",
"ryzenAdjBottomBar.reset": "Sıfırla", "ryzenAdjBottomBar.reset": "Sıfırla",
"app.localeSelectorModalTitle": "Dil değiştir", "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."
} }

View File

@ -114,6 +114,7 @@ type ApiPreset = {
}; };
type PresetsOnlineContextType = { type PresetsOnlineContextType = {
error: boolean;
loading: boolean; loading: boolean;
list: Array<ApiPreset>; list: Array<ApiPreset>;
update(): void; update(): void;

View File

@ -13,6 +13,7 @@ const uikit = window.require("uikit");
class PresetsScene extends React.Component<{}, PresetsOnlineContextType> { class PresetsScene extends React.Component<{}, PresetsOnlineContextType> {
_isMounted = false; _isMounted = false;
state: PresetsOnlineContextType = { state: PresetsOnlineContextType = {
error: false,
loading: false, loading: false,
list: [], list: [],
update: this.updatePresetList.bind(this), update: this.updatePresetList.bind(this),
@ -72,7 +73,10 @@ class PresetsScene extends React.Component<{}, PresetsOnlineContextType> {
fetch(process.env.REACT_APP_SERVER_ENDPOINT + "/presets", requestOption) fetch(process.env.REACT_APP_SERVER_ENDPOINT + "/presets", requestOption)
.then(response => response.json()) .then(response => response.json())
.then((data: Array<ApiPreset>) => { .then((data: Array<ApiPreset>) => {
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 });
}); });
} }