From 209dd43aacc22db256e789ea2ef8ebe2f85139c2 Mon Sep 17 00:00:00 2001 From: CEC Date: Wed, 13 Apr 2022 17:42:44 +0200 Subject: [PATCH] Deleted use of WAError and add defining of language of client everywhere --- front/src/Connexion/RoomConnection.ts | 3 +-- front/src/Phaser/Login/EntryScene.ts | 15 ++------------- front/src/Stores/ErrorScreenStore.ts | 5 +++-- pusher/src/Controller/IoSocketController.ts | 2 ++ pusher/src/Controller/MapController.ts | 2 ++ pusher/src/Services/AdminApi.ts | 2 +- 6 files changed, 11 insertions(+), 18 deletions(-) diff --git a/front/src/Connexion/RoomConnection.ts b/front/src/Connexion/RoomConnection.ts index a6e03cbc..ebee0e98 100644 --- a/front/src/Connexion/RoomConnection.ts +++ b/front/src/Connexion/RoomConnection.ts @@ -48,7 +48,6 @@ import { selectCharacterSceneVisibleStore } from "../Stores/SelectCharacterStore import { gameManager } from "../Phaser/Game/GameManager"; import { SelectCharacterScene, SelectCharacterSceneName } from "../Phaser/Login/SelectCharacterScene"; import { errorScreenStore } from "../Stores/ErrorScreenStore"; -import { WAError } from "../Phaser/Reconnecting/WAError"; const manualPingDelay = 20000; @@ -486,7 +485,7 @@ export class RoomConnection implements RoomConnection { this._errorScreenMessageStream.next(message.errorScreenMessage); if (message.errorScreenMessage.code !== "retry") this.closed = true; console.error("An error occurred server side: " + message.errorScreenMessage.code); - errorScreenStore.setError(message.errorScreenMessage as WAError); + errorScreenStore.setError(message.errorScreenMessage); break; } default: { diff --git a/front/src/Phaser/Login/EntryScene.ts b/front/src/Phaser/Login/EntryScene.ts index 3c9ce919..a8331b50 100644 --- a/front/src/Phaser/Login/EntryScene.ts +++ b/front/src/Phaser/Login/EntryScene.ts @@ -6,6 +6,7 @@ import { waScaleManager } from "../Services/WaScaleManager"; import { ReconnectingTextures } from "../Reconnecting/ReconnectingScene"; import { localeDetector } from "../../i18n/locales"; import { errorScreenStore } from "../../Stores/ErrorScreenStore"; +import {ErrorScreenMessage} from "../../Messages/ts-proto-generated/protos/messages"; export const EntrySceneName = "EntryScene"; @@ -47,19 +48,7 @@ export class EntryScene extends Scene { }) .catch((err) => { if (err.response.data?.code) { - errorScreenStore.setError( - new WAError( - err.response.data.type, - err.response.data.code, - err.response.data.title, - err.response.data.subtitle, - err.response.data.details, - err.response.data.timeToRetry, - err.response.data.canRetryManual, - err.response.data.urlToRedirect, - err.response.data.buttonTitle - ) - ); + errorScreenStore.setError(err.response.data); } else { ErrorScene.showError(err, this.scene); } diff --git a/front/src/Stores/ErrorScreenStore.ts b/front/src/Stores/ErrorScreenStore.ts index be00e03a..43b78d11 100644 --- a/front/src/Stores/ErrorScreenStore.ts +++ b/front/src/Stores/ErrorScreenStore.ts @@ -1,15 +1,16 @@ import { writable } from "svelte/store"; import { WAError } from "../Phaser/Reconnecting/WAError"; +import {ErrorScreenMessage} from "../Messages/ts-proto-generated/protos/messages"; /** * A store that contains one error of type WAError to be displayed. */ function createErrorScreenStore() { - const { subscribe, set } = writable(undefined); + const { subscribe, set } = writable(undefined); return { subscribe, - setError: (e: WAError): void => set(e), + setError: (e: ErrorScreenMessage): void => set(e), }; } diff --git a/pusher/src/Controller/IoSocketController.ts b/pusher/src/Controller/IoSocketController.ts index af3337cb..97af0faf 100644 --- a/pusher/src/Controller/IoSocketController.ts +++ b/pusher/src/Controller/IoSocketController.ts @@ -236,6 +236,8 @@ export class IoSocketController { const websocketExtensions = req.getHeader("sec-websocket-extensions"); const IPAddress = req.getHeader("x-forwarded-for"); + adminApi.setLocale(req.getHeader("accept-language")); + const roomId = query.roomId; try { if (typeof roomId !== "string") { diff --git a/pusher/src/Controller/MapController.ts b/pusher/src/Controller/MapController.ts index 19131a24..3893b4b9 100644 --- a/pusher/src/Controller/MapController.ts +++ b/pusher/src/Controller/MapController.ts @@ -107,6 +107,8 @@ export class MapController extends BaseHttpController { return; } + adminApi.setLocale(req.header("accept-language")); + // If no admin URL is set, let's react on '/_/[instance]/[map url]' URLs if (!ADMIN_API_URL) { const roomUrl = new URL(query.playUri); diff --git a/pusher/src/Services/AdminApi.ts b/pusher/src/Services/AdminApi.ts index 0cde82bd..5c239c12 100644 --- a/pusher/src/Services/AdminApi.ts +++ b/pusher/src/Services/AdminApi.ts @@ -29,7 +29,7 @@ export type FetchMemberDataByUuidResponse = z.infer