From 84f7a8c38329444d776a653f738344147525811d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20N=C3=A9grier?= Date: Mon, 6 Dec 2021 18:20:06 +0100 Subject: [PATCH] Pretty fix --- front/src/Connexion/Room.ts | 4 ++-- front/src/Phaser/Game/GameScene.ts | 2 +- front/src/Phaser/Reconnecting/ErrorScene.ts | 5 +--- front/src/Stores/ErrorStore.ts | 26 +++++++++++---------- 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/front/src/Connexion/Room.ts b/front/src/Connexion/Room.ts index 9603adf6..4b6d82a4 100644 --- a/front/src/Connexion/Room.ts +++ b/front/src/Connexion/Room.ts @@ -1,10 +1,10 @@ -import * as rax from 'retry-axios'; +import * as rax from "retry-axios"; import Axios from "axios"; import { CONTACT_URL, PUSHER_URL, DISABLE_ANONYMOUS, OPID_LOGIN_SCREEN_PROVIDER } from "../Enum/EnvironmentVariable"; import type { CharacterTexture } from "./LocalUser"; import { localUserStore } from "./LocalUserStore"; import axios from "axios"; -import {axiosWithRetry} from "./AxiosUtils"; +import { axiosWithRetry } from "./AxiosUtils"; export class MapDetail { constructor(public readonly mapUrl: string, public readonly textures: CharacterTexture[] | undefined) {} diff --git a/front/src/Phaser/Game/GameScene.ts b/front/src/Phaser/Game/GameScene.ts index 544387c3..58ba564e 100644 --- a/front/src/Phaser/Game/GameScene.ts +++ b/front/src/Phaser/Game/GameScene.ts @@ -270,7 +270,7 @@ export class GameScene extends DirtyScene { // So if we are in https, we can still try to load a HTTP local resource (can be useful for testing purposes) // See https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts#when_is_a_context_considered_secure const base = new URL(window.location.href); - base.pathname = ''; + base.pathname = ""; const url = new URL(file.src, base.toString()); const host = url.host.split(":")[0]; if ( diff --git a/front/src/Phaser/Reconnecting/ErrorScene.ts b/front/src/Phaser/Reconnecting/ErrorScene.ts index 82d9b746..078bee71 100644 --- a/front/src/Phaser/Reconnecting/ErrorScene.ts +++ b/front/src/Phaser/Reconnecting/ErrorScene.ts @@ -107,10 +107,7 @@ export class ErrorScene extends Phaser.Scene { } else if (Axios.isAxiosError(error)) { // Axios HTTP error // client never received a response, or request never left - console.error( - "Axios error. No full HTTP response received. Request to URL:", - error.config.url - ); + console.error("Axios error. No full HTTP response received. Request to URL:", error.config.url); scene.start(ErrorSceneName, { title: "Network error", subTitle: error.message, diff --git a/front/src/Stores/ErrorStore.ts b/front/src/Stores/ErrorStore.ts index 7db7ed32..3b6d7842 100644 --- a/front/src/Stores/ErrorStore.ts +++ b/front/src/Stores/ErrorStore.ts @@ -1,7 +1,7 @@ -import {derived, writable} from "svelte/store"; +import { derived, writable } from "svelte/store"; interface ErrorMessage { - id: string|undefined; + id: string | undefined; closable: boolean; // Whether it can be closed by a user action or not message: string | number | boolean | undefined; } @@ -14,10 +14,13 @@ function createErrorStore() { return { subscribe, - addErrorMessage: (e: string | Error, options?: { - closable?: boolean, - id?: string - }): void => { + addErrorMessage: ( + e: string | Error, + options?: { + closable?: boolean; + id?: string; + } + ): void => { update((messages: ErrorMessage[]) => { let message: string; if (e instanceof Error) { @@ -26,11 +29,11 @@ function createErrorStore() { message = e; } - if (!messages.find(errorMessage => errorMessage.message === message)) { + if (!messages.find((errorMessage) => errorMessage.message === message)) { messages.push({ message, closable: options?.closable ?? true, - id: options?.id + id: options?.id, }); } @@ -39,13 +42,13 @@ function createErrorStore() { }, clearMessageById: (id: string): void => { update((messages: ErrorMessage[]) => { - messages = messages.filter(message => message.id !== id); + messages = messages.filter((message) => message.id !== id); return messages; }); }, clearClosableMessages: (): void => { update((messages: ErrorMessage[]) => { - messages = messages.filter(message => message.closable); + messages = messages.filter((message) => message.closable); return messages; }); }, @@ -54,8 +57,7 @@ function createErrorStore() { export const errorStore = createErrorStore(); - export const hasClosableMessagesInErrorStore = derived(errorStore, ($errorStore) => { - const closableMessage = $errorStore.find(errorMessage => errorMessage.closable); + const closableMessage = $errorStore.find((errorMessage) => errorMessage.closable); return !!closableMessage; });