Add redirect directly without showing ErrorScreen

This commit is contained in:
CEC
2022-04-20 10:54:27 +02:00
parent 60ec09836b
commit 8d771d8442
2 changed files with 10 additions and 5 deletions
+9 -2
View File
@@ -5,6 +5,8 @@ import { waScaleManager } from "../Services/WaScaleManager";
import { ReconnectingTextures } from "../Reconnecting/ReconnectingScene";
import { localeDetector } from "../../i18n/locales";
import { errorScreenStore } from "../../Stores/ErrorScreenStore";
import {isErrorApiData} from "../../Messages/JsonMessages/ErrorApiData";
import {connectionManager} from "../../Connexion/ConnectionManager";
export const EntrySceneName = "EntryScene";
@@ -45,8 +47,13 @@ export class EntryScene extends Scene {
this.scene.start(nextSceneName);
})
.catch((err) => {
if (err?.response?.data?.code) {
errorScreenStore.setError(err.response.data);
const errorType = isErrorApiData.safeParse(err?.response?.data);
if (errorType.success) {
// If error from API and urlToRedirect is specified but not buttonTitle => redirect directly
if (!errorType.data.buttonTitle && errorType.data.urlToRedirect){
if (errorType.data.urlToRedirect === "/login") void connectionManager.logout();
else window.location.assign(errorType.data.urlToRedirect);
} else errorScreenStore.setError(err.response.data);
} else {
ErrorScene.showError(err, this.scene);
}