Deleted use of WAError and add defining of language of client everywhere

This commit is contained in:
CEC 2022-04-13 17:42:44 +02:00
parent 13b0996c8b
commit 209dd43aac
6 changed files with 11 additions and 18 deletions

View File

@ -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: {

View File

@ -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);
}

View File

@ -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<WAError>(undefined);
const { subscribe, set } = writable<ErrorScreenMessage>(undefined);
return {
subscribe,
setError: (e: WAError): void => set(e),
setError: (e: ErrorScreenMessage): void => set(e),
};
}

View File

@ -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") {

View File

@ -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);

View File

@ -29,7 +29,7 @@ export type FetchMemberDataByUuidResponse = z.infer<typeof isFetchMemberDataByUu
class AdminApi implements AdminInterface {
private locale: string = "en";
setLocale(locale: string) {
//console.info('PUSHER LOCALE SET TO :', locale);
console.info('PUSHER LOCALE SET TO :', locale);
this.locale = locale;
}
/**