Refactoring Error Screen

This commit is contained in:
CEC
2022-04-12 10:23:36 +02:00
parent e13fec1a8b
commit ecabdbe0c0
19 changed files with 315 additions and 61 deletions
+11 -6
View File
@@ -26,6 +26,11 @@ export const isFetchMemberDataByUuidResponse = z.object({
export type FetchMemberDataByUuidResponse = z.infer<typeof isFetchMemberDataByUuidResponse>;
class AdminApi {
private locale: string = 'en';
setLocale(locale: string){
//console.info('PUSHER LOCALE SET TO :', locale);
this.locale = locale;
}
/**
* @var playUri: is url of the room
* @var userId: can to be undefined or email or uuid
@@ -42,7 +47,7 @@ class AdminApi {
};
const res = await Axios.get<unknown, AxiosResponse<unknown>>(ADMIN_API_URL + "/api/map", {
headers: { Authorization: `${ADMIN_API_TOKEN}` },
headers: { Authorization: `${ADMIN_API_TOKEN}`, 'Accept-Language': this.locale },
params,
});
@@ -80,7 +85,7 @@ class AdminApi {
ipAddress,
characterLayers,
},
headers: { Authorization: `${ADMIN_API_TOKEN}` },
headers: { Authorization: `${ADMIN_API_TOKEN}`, 'Accept-Language': this.locale },
paramsSerializer: (p) => {
return qs.stringify(p, { arrayFormat: "brackets" });
},
@@ -106,7 +111,7 @@ class AdminApi {
//todo: this call can fail if the corresponding world is not activated or if the token is invalid. Handle that case.
const res = await Axios.get(ADMIN_API_URL + "/api/login-url/" + organizationMemberToken, {
params: { playUri },
headers: { Authorization: `${ADMIN_API_TOKEN}` },
headers: { Authorization: `${ADMIN_API_TOKEN}`, 'Accept-Language': this.locale },
});
const adminApiData = isAdminApiData.safeParse(res.data);
@@ -138,7 +143,7 @@ class AdminApi {
reportWorldSlug,
},
{
headers: { Authorization: `${ADMIN_API_TOKEN}` },
headers: { Authorization: `${ADMIN_API_TOKEN}`, 'Accept-Language': this.locale },
}
);
}
@@ -157,7 +162,7 @@ class AdminApi {
encodeURIComponent(userUuid) +
"&roomUrl=" +
encodeURIComponent(roomUrl),
{ headers: { Authorization: `${ADMIN_API_TOKEN}` } }
{ headers: { Authorization: `${ADMIN_API_TOKEN}`, 'Accept-Language': this.locale } }
).then((data) => {
return data.data;
});
@@ -169,7 +174,7 @@ class AdminApi {
}
return Axios.get(ADMIN_API_URL + "/api/room/sameWorld" + "?roomUrl=" + encodeURIComponent(roomUrl), {
headers: { Authorization: `${ADMIN_API_TOKEN}` },
headers: { Authorization: `${ADMIN_API_TOKEN}`, 'Accept-Language': this.locale },
}).then((data) => {
return data.data;
});
+21 -1
View File
@@ -39,7 +39,7 @@ import {
WorldFullMessage,
PlayerDetailsUpdatedMessage,
LockGroupPromptMessage,
InvalidTextureMessage,
InvalidTextureMessage, ErrorV2Message,
} from "../Messages/generated/messages_pb";
import { ProtobufUtils } from "../Model/Websocket/ProtobufUtils";
import { ADMIN_API_URL, JITSI_ISS, JITSI_URL, SECRET_JITSI_KEY } from "../Enum/EnvironmentVariable";
@@ -643,6 +643,26 @@ export class SocketManager implements ZoneEventListener {
client.send(serverToClientMessage.serializeBinary().buffer, true);
}
public emitErrorV2Message(client: compressors.WebSocket, type: string, code: string, title: string, subtitle: string, details: string, timeToRetry: number, canRetryManual: boolean, urlToRedirect: string, buttonTitle: string) {
const errorMessage = new ErrorV2Message();
errorMessage.setType(type);
errorMessage.setCode(code);
errorMessage.setTitle(title);
errorMessage.setSubtitle(subtitle);
errorMessage.setDetails(details);
errorMessage.setTimetoretry(timeToRetry);
errorMessage.setCanretrymanual(canRetryManual);
errorMessage.setUrltoredirect(urlToRedirect);
errorMessage.setButtontitle(buttonTitle);
const serverToClientMessage = new ServerToClientMessage();
serverToClientMessage.setErrorv2message(errorMessage);
//if (!client.disconnecting) {
client.send(serverToClientMessage.serializeBinary().buffer, true);
//}
}
private refreshRoomData(roomId: string, versionNumber: number): void {
const room = this.rooms.get(roomId);
//this function is run for every users connected to the room, so we need to make sure the room wasn't already refreshed.