Change lost connection page to the new one (#2161)

* Change lost connection page to the new one
This commit is contained in:
César Cardinale 2022-05-04 10:13:18 +02:00 committed by GitHub
parent fb9f8adb21
commit d47aad2ead
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 67 additions and 29 deletions

View File

@ -11,14 +11,17 @@
import reload from "../images/reload.png"; import reload from "../images/reload.png";
let errorScreen = get(errorScreenStore); let errorScreen = get(errorScreenStore);
import error from "./images/error.png";
let errorLogo = errorScreen?.image ?? error;
function click() { function click() {
if (errorScreen.type === "unauthorized") void connectionManager.logout(); if (errorScreen?.type === "unauthorized") void connectionManager.logout();
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") {
let interval = setInterval(() => { let interval = setInterval(() => {
if (timeVar <= 1000) click(); if (timeVar <= 1000) click();
timeVar -= 1000; timeVar -= 1000;
@ -29,15 +32,19 @@
$: detailsStylized = (details ?? "").replace("{time}", `${timeVar / 1000}`); $: detailsStylized = (details ?? "").replace("{time}", `${timeVar / 1000}`);
</script> </script>
{#if $errorScreenStore}
<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.image} alt="" class="icon" /></div> <div><img src={errorLogo} alt="Error logo" 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> {#if $errorScreenStore.subtitle}<p>{$errorScreenStore.subtitle}</p>{/if}
{#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"> <p class="details">
{detailsStylized}{#if $errorScreenStore.type === "retry"}<div class="loading" />{/if} {detailsStylized}
{#if $errorScreenStore.type === "retry" || $errorScreenStore.type === "reconnecting"}
<div class="loading" />
{/if}
</p> </p>
{#if ($errorScreenStore.type === "retry" && $errorScreenStore.canRetryManual) || $errorScreenStore.type === "unauthorized"} {#if ($errorScreenStore.type === "retry" && $errorScreenStore.canRetryManual) || $errorScreenStore.type === "unauthorized"}
<button type="button" class="nes-btn is-primary button" on:click={click}> <button type="button" class="nes-btn is-primary button" on:click={click}>
@ -47,6 +54,7 @@
{/if} {/if}
</div> </div>
</main> </main>
{/if}
<style lang="scss"> <style lang="scss">
main.errorScreen { main.errorScreen {

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

View File

@ -76,6 +76,7 @@ import { contactPageStore } from "../../Stores/MenuStore";
import type { WasCameraUpdatedEvent } from "../../Api/Events/WasCameraUpdatedEvent"; import type { WasCameraUpdatedEvent } from "../../Api/Events/WasCameraUpdatedEvent";
import { audioManagerFileStore } from "../../Stores/AudioManagerStore"; import { audioManagerFileStore } from "../../Stores/AudioManagerStore";
import { currentPlayerGroupLockStateStore } from "../../Stores/CurrentPlayerGroupStore"; import { currentPlayerGroupLockStateStore } from "../../Stores/CurrentPlayerGroupStore";
import { errorScreenStore } from "../../Stores/ErrorScreenStore";
import EVENT_TYPE = Phaser.Scenes.Events; import EVENT_TYPE = Phaser.Scenes.Events;
import Texture = Phaser.Textures.Texture; import Texture = Phaser.Textures.Texture;
@ -90,7 +91,7 @@ import FILE_LOAD_ERROR = Phaser.Loader.Events.FILE_LOAD_ERROR;
import { MapStore } from "../../Stores/Utils/MapStore"; import { MapStore } from "../../Stores/Utils/MapStore";
import { followUsersColorStore } from "../../Stores/FollowStore"; import { followUsersColorStore } from "../../Stores/FollowStore";
import { GameSceneUserInputHandler } from "../UserInput/GameSceneUserInputHandler"; import { GameSceneUserInputHandler } from "../UserInput/GameSceneUserInputHandler";
import { locale } from "../../i18n/i18n-svelte"; import LL, { locale } from "../../i18n/i18n-svelte";
import { availabilityStatusStore, localVolumeStore } from "../../Stores/MediaStore"; import { availabilityStatusStore, localVolumeStore } from "../../Stores/MediaStore";
import { StringUtils } from "../../Utils/StringUtils"; import { StringUtils } from "../../Utils/StringUtils";
import { startLayerNamesStore } from "../../Stores/StartLayerNamesStore"; import { startLayerNamesStore } from "../../Stores/StartLayerNamesStore";
@ -100,7 +101,7 @@ import type { CoWebsite } from "../../WebRtc/CoWebsite/CoWesbite";
import CancelablePromise from "cancelable-promise"; import CancelablePromise from "cancelable-promise";
import { Deferred } from "ts-deferred"; import { Deferred } from "ts-deferred";
import { SuperLoaderPlugin } from "../Services/SuperLoaderPlugin"; import { SuperLoaderPlugin } from "../Services/SuperLoaderPlugin";
import { PlayerDetailsUpdatedMessage } from "../../Messages/ts-proto-generated/protos/messages"; import { ErrorScreenMessage, PlayerDetailsUpdatedMessage } from "../../Messages/ts-proto-generated/protos/messages";
export interface GameSceneInitInterface { export interface GameSceneInitInterface {
initPosition: PointInterface | null; initPosition: PointInterface | null;
reconnecting: boolean; reconnecting: boolean;
@ -597,14 +598,30 @@ export class GameScene extends DirtyScene {
if (this.isReconnecting) { if (this.isReconnecting) {
setTimeout(() => { setTimeout(() => {
this.scene.sleep(); this.scene.sleep();
this.scene.launch(ReconnectingSceneName); errorScreenStore.setError(
ErrorScreenMessage.fromPartial({
type: "reconnecting",
code: "CONNECTION_LOST",
title: get(LL).warning.connectionLostTitle(),
details: get(LL).warning.connectionLostSubtitle(),
})
);
//this.scene.launch(ReconnectingSceneName);
}, 0); }, 0);
} else if (this.connection === undefined) { } else if (this.connection === undefined) {
// Let's wait 1 second before printing the "connecting" screen to avoid blinking // Let's wait 1 second before printing the "connecting" screen to avoid blinking
setTimeout(() => { setTimeout(() => {
if (this.connection === undefined) { if (this.connection === undefined) {
this.scene.sleep(); this.scene.sleep();
this.scene.launch(ReconnectingSceneName); errorScreenStore.setError(
ErrorScreenMessage.fromPartial({
type: "reconnecting",
code: "CONNECTION_LOST",
title: get(LL).warning.connectionLostTitle(),
details: get(LL).warning.connectionLostSubtitle(),
})
);
//this.scene.launch(ReconnectingSceneName);
} }
}, 1000); }, 1000);
} }
@ -888,7 +905,9 @@ export class GameScene extends DirtyScene {
// Analyze tags to find if we are admin. If yes, show console. // Analyze tags to find if we are admin. If yes, show console.
if (this.scene.isSleeping()) { if (this.scene.isSleeping()) {
this.scene.stop(ReconnectingSceneName); const error = get(errorScreenStore);
if (error && error?.type === "reconnecting") errorScreenStore.delete();
//this.scene.stop(ReconnectingSceneName);
} }
//init user position and play trigger to check layers properties //init user position and play trigger to check layers properties

View File

@ -5,13 +5,16 @@ import { ErrorScreenMessage } from "../Messages/ts-proto-generated/protos/messag
* A store that contains one error of type WAError to be displayed. * A store that contains one error of type WAError to be displayed.
*/ */
function createErrorScreenStore() { function createErrorScreenStore() {
const { subscribe, set } = writable<ErrorScreenMessage>(undefined); const { subscribe, set } = writable<ErrorScreenMessage | undefined>(undefined);
return { return {
subscribe, subscribe,
setError: (e: ErrorScreenMessage): void => { setError: (e: ErrorScreenMessage): void => {
set(e); set(e);
}, },
delete: () => {
set(undefined);
},
}; };
} }

View File

@ -14,6 +14,8 @@ const warning: NonNullable<Translation["warning"]> = {
}, },
importantMessage: "Wichtige Nachricht", importantMessage: "Wichtige Nachricht",
connectionLost: "Verbindungen unterbrochen. Wiederverbinden...", connectionLost: "Verbindungen unterbrochen. Wiederverbinden...",
connectionLostTitle: "Verbindungen unterbrochen",
connectionLostSubtitle: "Wiederverbinden",
}; };
export default warning; export default warning;

View File

@ -13,6 +13,8 @@ const warning: BaseTranslation = {
}, },
importantMessage: "Important message", importantMessage: "Important message",
connectionLost: "Connection lost. Reconnecting...", connectionLost: "Connection lost. Reconnecting...",
connectionLostTitle: "Connection lost",
connectionLostSubtitle: "Reconnecting",
}; };
export default warning; export default warning;

View File

@ -121,7 +121,7 @@ const menu: NonNullable<Translation["menu"]> = {
}, },
}, },
sub: { sub: {
profile: "Profile", profile: "Profil",
settings: "Paramètres", settings: "Paramètres",
invite: "Inviter", invite: "Inviter",
credit: "Crédits", credit: "Crédits",

View File

@ -13,6 +13,8 @@ const warning: NonNullable<Translation["warning"]> = {
}, },
importantMessage: "Message important", importantMessage: "Message important",
connectionLost: "Connexion perdue. Reconnexion...", connectionLost: "Connexion perdue. Reconnexion...",
connectionLostTitle: "Connexion perdue",
connectionLostSubtitle: "Reconnexion",
}; };
export default warning; export default warning;

View File

@ -13,6 +13,8 @@ const warning: NonNullable<Translation["warning"]> = {
}, },
importantMessage: "重要消息", importantMessage: "重要消息",
connectionLost: "连接丢失。重新连接中...", connectionLost: "连接丢失。重新连接中...",
connectionLostTitle: "连接丢失。",
connectionLostSubtitle: "重新连接中",
}; };
export default warning; export default warning;