Fix prettier issues

This commit is contained in:
CEC 2022-04-21 14:45:34 +02:00
parent bc17b86ce4
commit 91e8fa7cd4
8 changed files with 21 additions and 29 deletions

View File

@ -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}`);
</script>
<main class="errorScreen" transition:fly={{ y: -200, duration: 500 }}>
@ -44,9 +37,9 @@
<p class="details">
{detailsStylized}{#if $errorScreenStore.type === "retry"}<div class="loading" />{/if}
</p>
{#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}
<button type="button" class="nes-btn is-primary button" on:click={click}>
<img src={$errorScreenStore.type === "retry" ? reload : external} alt="" class="reload" />
<img src={reload} alt="" class="reload" />
{$errorScreenStore.buttonTitle}
</button>
{/if}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

View File

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

View File

@ -10,7 +10,7 @@ function createErrorScreenStore() {
return {
subscribe,
setError: (e: ErrorScreenMessage): void => {
set(e)
set(e);
},
};
}

View File

@ -43,9 +43,4 @@ export const isErrorApiData = z.discriminatedUnion("type", [
isErrorApiUnauthorizedData,
]);
export type ErrorApiErrorData = z.infer<typeof isErrorApiErrorData>;
export type ErrorApiRetryData = z.infer<typeof isErrorApiRetryData>;
export type ErrorApiRedirectData = z.infer<typeof isErrorApiRedirectData>;
export type ErrorApiUnauthorizedData = z.infer<typeof isErrorApiUnauthorizedData>;
export type ErrorApiData = z.infer<typeof isErrorApiData>;

View File

@ -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",

View File

@ -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,

View File

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