Pretty fix
This commit is contained in:
parent
c27662c315
commit
84f7a8c383
@ -1,10 +1,10 @@
|
|||||||
import * as rax from 'retry-axios';
|
import * as rax from "retry-axios";
|
||||||
import Axios from "axios";
|
import Axios from "axios";
|
||||||
import { CONTACT_URL, PUSHER_URL, DISABLE_ANONYMOUS, OPID_LOGIN_SCREEN_PROVIDER } from "../Enum/EnvironmentVariable";
|
import { CONTACT_URL, PUSHER_URL, DISABLE_ANONYMOUS, OPID_LOGIN_SCREEN_PROVIDER } from "../Enum/EnvironmentVariable";
|
||||||
import type { CharacterTexture } from "./LocalUser";
|
import type { CharacterTexture } from "./LocalUser";
|
||||||
import { localUserStore } from "./LocalUserStore";
|
import { localUserStore } from "./LocalUserStore";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import {axiosWithRetry} from "./AxiosUtils";
|
import { axiosWithRetry } from "./AxiosUtils";
|
||||||
|
|
||||||
export class MapDetail {
|
export class MapDetail {
|
||||||
constructor(public readonly mapUrl: string, public readonly textures: CharacterTexture[] | undefined) {}
|
constructor(public readonly mapUrl: string, public readonly textures: CharacterTexture[] | undefined) {}
|
||||||
|
@ -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)
|
// 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
|
// 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);
|
const base = new URL(window.location.href);
|
||||||
base.pathname = '';
|
base.pathname = "";
|
||||||
const url = new URL(file.src, base.toString());
|
const url = new URL(file.src, base.toString());
|
||||||
const host = url.host.split(":")[0];
|
const host = url.host.split(":")[0];
|
||||||
if (
|
if (
|
||||||
|
@ -107,10 +107,7 @@ export class ErrorScene extends Phaser.Scene {
|
|||||||
} else if (Axios.isAxiosError(error)) {
|
} else if (Axios.isAxiosError(error)) {
|
||||||
// Axios HTTP error
|
// Axios HTTP error
|
||||||
// client never received a response, or request never left
|
// client never received a response, or request never left
|
||||||
console.error(
|
console.error("Axios error. No full HTTP response received. Request to URL:", error.config.url);
|
||||||
"Axios error. No full HTTP response received. Request to URL:",
|
|
||||||
error.config.url
|
|
||||||
);
|
|
||||||
scene.start(ErrorSceneName, {
|
scene.start(ErrorSceneName, {
|
||||||
title: "Network error",
|
title: "Network error",
|
||||||
subTitle: error.message,
|
subTitle: error.message,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import {derived, writable} from "svelte/store";
|
import { derived, writable } from "svelte/store";
|
||||||
|
|
||||||
interface ErrorMessage {
|
interface ErrorMessage {
|
||||||
id: string|undefined;
|
id: string | undefined;
|
||||||
closable: boolean; // Whether it can be closed by a user action or not
|
closable: boolean; // Whether it can be closed by a user action or not
|
||||||
message: string | number | boolean | undefined;
|
message: string | number | boolean | undefined;
|
||||||
}
|
}
|
||||||
@ -14,10 +14,13 @@ function createErrorStore() {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
subscribe,
|
subscribe,
|
||||||
addErrorMessage: (e: string | Error, options?: {
|
addErrorMessage: (
|
||||||
closable?: boolean,
|
e: string | Error,
|
||||||
id?: string
|
options?: {
|
||||||
}): void => {
|
closable?: boolean;
|
||||||
|
id?: string;
|
||||||
|
}
|
||||||
|
): void => {
|
||||||
update((messages: ErrorMessage[]) => {
|
update((messages: ErrorMessage[]) => {
|
||||||
let message: string;
|
let message: string;
|
||||||
if (e instanceof Error) {
|
if (e instanceof Error) {
|
||||||
@ -26,11 +29,11 @@ function createErrorStore() {
|
|||||||
message = e;
|
message = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!messages.find(errorMessage => errorMessage.message === message)) {
|
if (!messages.find((errorMessage) => errorMessage.message === message)) {
|
||||||
messages.push({
|
messages.push({
|
||||||
message,
|
message,
|
||||||
closable: options?.closable ?? true,
|
closable: options?.closable ?? true,
|
||||||
id: options?.id
|
id: options?.id,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,13 +42,13 @@ function createErrorStore() {
|
|||||||
},
|
},
|
||||||
clearMessageById: (id: string): void => {
|
clearMessageById: (id: string): void => {
|
||||||
update((messages: ErrorMessage[]) => {
|
update((messages: ErrorMessage[]) => {
|
||||||
messages = messages.filter(message => message.id !== id);
|
messages = messages.filter((message) => message.id !== id);
|
||||||
return messages;
|
return messages;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
clearClosableMessages: (): void => {
|
clearClosableMessages: (): void => {
|
||||||
update((messages: ErrorMessage[]) => {
|
update((messages: ErrorMessage[]) => {
|
||||||
messages = messages.filter(message => message.closable);
|
messages = messages.filter((message) => message.closable);
|
||||||
return messages;
|
return messages;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -54,8 +57,7 @@ function createErrorStore() {
|
|||||||
|
|
||||||
export const errorStore = createErrorStore();
|
export const errorStore = createErrorStore();
|
||||||
|
|
||||||
|
|
||||||
export const hasClosableMessagesInErrorStore = derived(errorStore, ($errorStore) => {
|
export const hasClosableMessagesInErrorStore = derived(errorStore, ($errorStore) => {
|
||||||
const closableMessage = $errorStore.find(errorMessage => errorMessage.closable);
|
const closableMessage = $errorStore.find((errorMessage) => errorMessage.closable);
|
||||||
return !!closableMessage;
|
return !!closableMessage;
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user