Fix prettier for the front

This commit is contained in:
CEC 2022-04-12 11:22:58 +02:00
parent 074f43d16c
commit d972b3a2e6
6 changed files with 149 additions and 141 deletions

View File

@ -16,7 +16,6 @@
import ErrorDialog from "./UI/ErrorDialog.svelte"; import ErrorDialog from "./UI/ErrorDialog.svelte";
import ErrorScreen from "./UI/ErrorScreen.svelte"; import ErrorScreen from "./UI/ErrorScreen.svelte";
export let game: Game; export let game: Game;
</script> </script>

View File

@ -13,12 +13,12 @@
function click() { function click() {
if (errorScreen.urlToRedirect) window.location.replace(errorScreen.urlToRedirect); if (errorScreen.urlToRedirect) window.location.replace(errorScreen.urlToRedirect);
else if(errorScreen.type === 'redirect' && window.history.length > 2) history.back(); else if (errorScreen.type === "redirect" && window.history.length > 2) history.back();
else window.location.reload(); else window.location.reload();
} }
let details = errorScreen.details; let details = errorScreen.details;
let timeVar = errorScreen.timeToRetry ?? 0; let timeVar = errorScreen.timeToRetry ?? 0;
if(errorScreen.type === 'retry') { if (errorScreen.type === "retry") {
setInterval(() => { setInterval(() => {
if (timeVar <= 1000) click(); if (timeVar <= 1000) click();
timeVar -= 1000; timeVar -= 1000;
@ -26,25 +26,25 @@
} }
$: detailsStylized = details.replace("{time}", `${timeVar / 1000}`); $: detailsStylized = details.replace("{time}", `${timeVar / 1000}`);
</script> </script>
<main class="errorScreen" transition:fly={{ y: -200, duration: 500 }}> <main class="errorScreen" transition:fly={{ y: -200, duration: 500 }}>
<div style="width: 90%;"> <div style="width: 90%;">
<img src={logo} alt="WorkAdventure" class="logo" /> <img src={logo} alt="WorkAdventure" class="logo" />
<div><img src={$errorScreenStore.type === 'retry'?cup:error} alt="" class="icon"/></div> <div><img src={$errorScreenStore.type === "retry" ? cup : error} alt="" class="icon" /></div>
{#if $errorScreenStore.type !== 'retry'}<h2>{$errorScreenStore.title}</h2>{/if} {#if $errorScreenStore.type !== "retry"}<h2>{$errorScreenStore.title}</h2>{/if}
<p>{$errorScreenStore.subtitle}</p> <p>{$errorScreenStore.subtitle}</p>
{#if $errorScreenStore.type !== 'retry'}<p class="code">Code : {$errorScreenStore.code}</p>{/if} {#if $errorScreenStore.type !== "retry"}<p class="code">Code : {$errorScreenStore.code}</p>{/if}
<p class="details">{detailsStylized}{#if $errorScreenStore.type === 'retry'}<div class="loading"></div>{/if}</p> <p class="details">
{#if ($errorScreenStore.type === 'retry' && $errorScreenStore.canRetryManual) || ($errorScreenStore.type === 'redirect' && (window.history.length > 2 || $errorScreenStore.urlToRedirect))} {detailsStylized}{#if $errorScreenStore.type === "retry"}<div class="loading" />{/if}
</p>
{#if ($errorScreenStore.type === "retry" && $errorScreenStore.canRetryManual) || ($errorScreenStore.type === "redirect" && (window.history.length > 2 || $errorScreenStore.urlToRedirect))}
<div class="button" on:click={click}> <div class="button" on:click={click}>
<img src={$errorScreenStore.type === 'retry'?reload:external} alt="" class="reload"/> <img src={$errorScreenStore.type === "retry" ? reload : external} alt="" class="reload" />
{$errorScreenStore.buttonTitle} {$errorScreenStore.buttonTitle}
</div> </div>
{/if} {/if}
</div> </div>
</main> </main>
<style lang="scss"> <style lang="scss">
@ -52,7 +52,7 @@
pointer-events: auto; pointer-events: auto;
width: 100%; width: 100%;
background-color: #000000; background-color: #000000;
color: #FFFFFF; color: #ffffff;
text-align: center; text-align: center;
position: absolute; position: absolute;
display: flex; display: flex;
@ -87,7 +87,7 @@
} }
p.code { p.code {
font-size: 12px; font-size: 12px;
opacity: .6; opacity: 0.6;
user-select: text; user-select: text;
} }
p.details { p.details {
@ -130,7 +130,7 @@
.button { .button {
cursor: pointer; cursor: pointer;
background-image: url('../images/button-large.png'); background-image: url("../images/button-large.png");
background-position: center; background-position: center;
background-repeat: no-repeat; background-repeat: no-repeat;
background-size: contain; background-size: contain;
@ -153,6 +153,5 @@
width: 24px; width: 24px;
} }
} }
} }
</style> </style>

View File

@ -483,7 +483,7 @@ export class RoomConnection implements RoomConnection {
} }
case "errorV2Message": { case "errorV2Message": {
this._errorV2MessageStream.next(message.errorV2Message); this._errorV2MessageStream.next(message.errorV2Message);
if(message.errorV2Message.code !== 'retry') this.closed = true; if (message.errorV2Message.code !== "retry") this.closed = true;
console.error("An error occurred server side: " + message.errorV2Message.code); console.error("An error occurred server side: " + message.errorV2Message.code);
errorScreenStore.setError(message.errorV2Message as unknown as WAError); errorScreenStore.setError(message.errorV2Message as unknown as WAError);
break; break;

View File

@ -47,7 +47,8 @@ export class EntryScene extends Scene {
}) })
.catch((err) => { .catch((err) => {
if (err.response.data?.code) { if (err.response.data?.code) {
errorScreenStore.setError(new WAError( errorScreenStore.setError(
new WAError(
err.response.data.type, err.response.data.type,
err.response.data.code, err.response.data.code,
err.response.data.title, err.response.data.title,
@ -57,7 +58,8 @@ export class EntryScene extends Scene {
err.response.data.canRetryManual, err.response.data.canRetryManual,
err.response.data.urlToRedirect, err.response.data.urlToRedirect,
err.response.data.buttonTitle err.response.data.buttonTitle
)); )
);
} else { } else {
ErrorScene.showError(err, this.scene); ErrorScene.showError(err, this.scene);
} }

View File

@ -9,7 +9,17 @@ export class WAError extends Error {
private _urlToRedirect: string; private _urlToRedirect: string;
private _buttonTitle: string; private _buttonTitle: string;
constructor(type: string, code: string, title: string, subtitle: string, details: string, timeToRetry: number, canRetryManual: boolean, urlToRedirect: string, buttonTitle: string) { constructor(
type: string,
code: string,
title: string,
subtitle: string,
details: string,
timeToRetry: number,
canRetryManual: boolean,
urlToRedirect: string,
buttonTitle: string
) {
super(title + " - " + subtitle + " - " + details); super(title + " - " + subtitle + " - " + details);
this._type = type; this._type = type;

View File

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