From 91e8fa7cd46b508b3f58d9ff12d0b85446751f39 Mon Sep 17 00:00:00 2001
From: CEC
Date: Thu, 21 Apr 2022 14:45:34 +0200
Subject: [PATCH] Fix prettier issues
---
front/src/Components/UI/ErrorScreen.svelte | 15 ++++----------
front/src/Components/images/external-link.png | Bin 10701 -> 0 bytes
front/src/Phaser/Login/EntryScene.ts | 4 ++--
front/src/Stores/ErrorScreenStore.ts | 2 +-
messages/JsonMessages/ErrorApiData.ts | 5 -----
pusher/package.json | 2 ++
pusher/src/Controller/IoSocketController.ts | 3 +--
pusher/src/Services/SocketManager.ts | 19 ++++++++++--------
8 files changed, 21 insertions(+), 29 deletions(-)
delete mode 100644 front/src/Components/images/external-link.png
diff --git a/front/src/Components/UI/ErrorScreen.svelte b/front/src/Components/UI/ErrorScreen.svelte
index 71b33456..bac59594 100644
--- a/front/src/Components/UI/ErrorScreen.svelte
+++ b/front/src/Components/UI/ErrorScreen.svelte
@@ -8,17 +8,10 @@
import logoImg from "../images/logo-min-white.png";
let logo = gameManager?.currentStartedRoom?.loginSceneLogo ?? logoImg;
import reload from "../images/reload.png";
- import external from "../images/external-link.png";
- import { connectionManager } from "../../Connexion/ConnectionManager";
-
let errorScreen = get(errorScreenStore);
function click() {
- if (errorScreen.urlToRedirect) {
- if (errorScreen.urlToRedirect === "/login") void connectionManager.logout();
- else window.location.assign(errorScreen.urlToRedirect);
- } else if (errorScreen.type === "redirect" && window.history.length > 2) history.back();
- else window.location.reload();
+ window.location.reload();
}
let details = errorScreen.details;
let timeVar = errorScreen.timeToRetry ?? 0;
@@ -31,7 +24,7 @@
onDestroy(() => clearInterval(interval));
}
- $: detailsStylized = details.replace("{time}", `${timeVar / 1000}`);
+ $: detailsStylized = (details ?? "").replace("{time}", `${timeVar / 1000}`);
@@ -44,9 +37,9 @@
{detailsStylized}{#if $errorScreenStore.type === "retry"}
{/if}
- {#if ($errorScreenStore.type === "retry" && $errorScreenStore.canRetryManual) || ($errorScreenStore.type === "unauthorized" && $errorScreenStore.urlToRedirect && $errorScreenStore.buttonTitle) || ($errorScreenStore.type === "redirect" && (window.history.length > 2 || $errorScreenStore.urlToRedirect))}
+ {#if $errorScreenStore.type === "retry" && $errorScreenStore.canRetryManual}
{/if}
diff --git a/front/src/Components/images/external-link.png b/front/src/Components/images/external-link.png
deleted file mode 100644
index 52fca4ed38534972759e400790239bf642198fc8..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 10701
zcmeAS@N?(olHy`uVBq!ia0y~yU=0W2NDeljNXA<0p9~BN44y8IAr*7p+;Pl}4is^{
z_+5*cqs75P@JeF{i?4u45Ran3p(kOou9Bg5FKtiB*5!C!7x_tU&t3+GhTR6n>C;&l
zcFf{06lGv|cjQb@G!sM2+1KXL%s}%Q{@8z-};zHi3t<{#S{qQ7joR#jyAKy2={sQoc~3=dYZ81QZUUbjuBAUo~Zo@-Ub
z77xTK#Xx1zXrVM(CIeH!Xq7aY7iduwG)=x}abtBONFy
zc)9|XQ4993WtMqy?fJ6hM-r+|ke&
zO$?)Xfoes;hV(R^BQoe)pm2B8B7CpS!1TzGn!?=RKO51z_!{?Adn{|H$42z0ClHAWa3cYubr
z2OIa`t?K;4g{PvjCB=b`YltrSxQfAG^Y^-0Gu?v=PMnTkhWeBZ{}uz%NQe&&7J=A)xDz#ts$wt!OkXemEh%F`q-?2zDP
z*k^P8%xq1ICx3^GrC>@)ZQ3vb%8=*wA>rc62N&};#-=l;7z*I0g6*8I^Xi^kRpIK=v0}5O77q0>>)6(o14?T^H*k9Hd3KH~m
L^>bP0l+XkKddGK2
diff --git a/front/src/Phaser/Login/EntryScene.ts b/front/src/Phaser/Login/EntryScene.ts
index 02579af1..dce7216d 100644
--- a/front/src/Phaser/Login/EntryScene.ts
+++ b/front/src/Phaser/Login/EntryScene.ts
@@ -49,9 +49,9 @@ export class EntryScene extends Scene {
.catch((err) => {
const errorType = isErrorApiData.safeParse(err?.response?.data);
if (errorType.success) {
- if (errorType.data.type === 'unauthorized') {
+ if (errorType.data.type === "unauthorized") {
void connectionManager.logout();
- } else if (errorType.data.type === 'redirect') {
+ } else if (errorType.data.type === "redirect") {
window.location.assign(errorType.data.urlToRedirect);
} else errorScreenStore.setError(err?.response?.data);
} else {
diff --git a/front/src/Stores/ErrorScreenStore.ts b/front/src/Stores/ErrorScreenStore.ts
index a9081b21..564afb92 100644
--- a/front/src/Stores/ErrorScreenStore.ts
+++ b/front/src/Stores/ErrorScreenStore.ts
@@ -10,7 +10,7 @@ function createErrorScreenStore() {
return {
subscribe,
setError: (e: ErrorScreenMessage): void => {
- set(e)
+ set(e);
},
};
}
diff --git a/messages/JsonMessages/ErrorApiData.ts b/messages/JsonMessages/ErrorApiData.ts
index e9ea4e55..0fbf3db7 100644
--- a/messages/JsonMessages/ErrorApiData.ts
+++ b/messages/JsonMessages/ErrorApiData.ts
@@ -43,9 +43,4 @@ export const isErrorApiData = z.discriminatedUnion("type", [
isErrorApiUnauthorizedData,
]);
-export type ErrorApiErrorData = z.infer;
-export type ErrorApiRetryData = z.infer;
-export type ErrorApiRedirectData = z.infer;
-export type ErrorApiUnauthorizedData = z.infer;
-
export type ErrorApiData = z.infer;
diff --git a/pusher/package.json b/pusher/package.json
index 22f6960e..cbd5375e 100644
--- a/pusher/package.json
+++ b/pusher/package.json
@@ -40,6 +40,7 @@
},
"homepage": "https://github.com/thecodingmachine/workadventure#readme",
"dependencies": {
+ "@anatine/zod-openapi": "^1.3.0",
"axios": "^0.21.2",
"circular-json": "^0.5.9",
"debug": "^4.3.1",
@@ -48,6 +49,7 @@
"hyper-express": "^5.8.1",
"jsonwebtoken": "^8.5.1",
"mkdirp": "^1.0.4",
+ "openapi3-ts": "^2.0.2",
"openid-client": "^4.7.4",
"prom-client": "^12.0.0",
"qs": "^6.10.3",
diff --git a/pusher/src/Controller/IoSocketController.ts b/pusher/src/Controller/IoSocketController.ts
index 3912d951..d985261a 100644
--- a/pusher/src/Controller/IoSocketController.ts
+++ b/pusher/src/Controller/IoSocketController.ts
@@ -247,7 +247,6 @@ export class IoSocketController {
const IPAddress = req.getHeader("x-forwarded-for");
const locale = req.getHeader("accept-language");
-
const roomId = query.roomId;
try {
if (typeof roomId !== "string") {
@@ -345,7 +344,7 @@ export class IoSocketController {
reason: null,
status: 500,
message: err?.response?.data,
- roomId: roomId
+ roomId: roomId,
} as UpgradeFailedData,
websocketKey,
websocketProtocol,
diff --git a/pusher/src/Services/SocketManager.ts b/pusher/src/Services/SocketManager.ts
index 1476e89a..5bbfe32c 100644
--- a/pusher/src/Services/SocketManager.ts
+++ b/pusher/src/Services/SocketManager.ts
@@ -59,9 +59,10 @@ import {
ErrorApiData,
isErrorApiErrorData,
isErrorApiRedirectData,
- isErrorApiRetryData, isErrorApiUnauthorizedData
+ isErrorApiRetryData,
+ isErrorApiUnauthorizedData,
} from "../Messages/JsonMessages/ErrorApiData";
-import {BoolValue, Int32Value, StringValue} from "google-protobuf/google/protobuf/wrappers_pb";
+import { BoolValue, Int32Value, StringValue } from "google-protobuf/google/protobuf/wrappers_pb";
const debug = Debug("socket");
@@ -681,20 +682,22 @@ export class SocketManager implements ZoneEventListener {
public emitErrorScreenMessage(client: compressors.WebSocket, errorApi: ErrorApiData) {
const errorMessage = new ErrorScreenMessage();
errorMessage.setType(errorApi.type);
- if(errorApi.type == 'retry' || errorApi.type == 'error'){
+ if (errorApi.type == "retry" || errorApi.type == "error") {
errorMessage.setCode(new StringValue().setValue(errorApi.code));
errorMessage.setTitle(new StringValue().setValue(errorApi.title));
errorMessage.setSubtitle(new StringValue().setValue(errorApi.subtitle));
errorMessage.setDetails(new StringValue().setValue(errorApi.details));
errorMessage.setImage(new StringValue().setValue(errorApi.image));
}
- if(errorApi.type == 'retry') {
+ if (errorApi.type == "retry") {
if (errorApi.buttonTitle) errorMessage.setButtontitle(new StringValue().setValue(errorApi.buttonTitle));
- if (errorApi.canRetryManual !== undefined) errorMessage.setCanretrymanual(new BoolValue().setValue(errorApi.canRetryManual));
- if (errorApi.timeToRetry) errorMessage.setTimetoretry(new Int32Value().setValue(Number(errorApi.timeToRetry)));
+ if (errorApi.canRetryManual !== undefined)
+ errorMessage.setCanretrymanual(new BoolValue().setValue(errorApi.canRetryManual));
+ if (errorApi.timeToRetry)
+ errorMessage.setTimetoretry(new Int32Value().setValue(Number(errorApi.timeToRetry)));
}
- if(errorApi.type == 'redirect' && errorApi.urlToRedirect) errorMessage.setUrltoredirect(new StringValue().setValue(errorApi.urlToRedirect));
-
+ if (errorApi.type == "redirect" && errorApi.urlToRedirect)
+ errorMessage.setUrltoredirect(new StringValue().setValue(errorApi.urlToRedirect));
const serverToClientMessage = new ServerToClientMessage();
serverToClientMessage.setErrorscreenmessage(errorMessage);