From 71a0e180494e8ed2cb0773c63ea5603510735a8c Mon Sep 17 00:00:00 2001
From: CEC
Date: Tue, 19 Apr 2022 17:31:43 +0200
Subject: [PATCH] Disconnect and redirect to login on error page
---
front/src/Components/UI/ErrorScreen.svelte | 11 ++++++++---
pusher/src/Services/SocketManager.ts | 2 +-
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/front/src/Components/UI/ErrorScreen.svelte b/front/src/Components/UI/ErrorScreen.svelte
index 7408ea82..a9974ae3 100644
--- a/front/src/Components/UI/ErrorScreen.svelte
+++ b/front/src/Components/UI/ErrorScreen.svelte
@@ -9,12 +9,17 @@
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);
+ if(!errorScreen.buttonTitle && errorScreen.urlToRedirect) window.location.replace(errorScreen.urlToRedirect);
+
function click() {
- if (errorScreen.urlToRedirect) window.location.replace(errorScreen.urlToRedirect);
- else if (errorScreen.type === "redirect" && window.history.length > 2) history.back();
+ if (errorScreen.urlToRedirect){
+ if(errorScreen.urlToRedirect === '/login') connectionManager.logout();
+ window.location.replace(errorScreen.urlToRedirect);
+ } else if (errorScreen.type === "redirect" && window.history.length > 2) history.back();
else window.location.reload();
}
let details = errorScreen.details;
@@ -41,7 +46,7 @@
{detailsStylized}{#if $errorScreenStore.type === "retry"}
{/if}
- {#if ($errorScreenStore.type === "retry" && $errorScreenStore.canRetryManual) || ($errorScreenStore.type === "redirect" && (window.history.length > 2 || $errorScreenStore.urlToRedirect))}
+ {#if ($errorScreenStore.type === "retry" && $errorScreenStore.canRetryManual) || ($errorScreenStore.type === "unauthorized" && $errorScreenStore.urlToRedirect && $errorScreenStore.buttonTitle) || ($errorScreenStore.type === "redirect" && (window.history.length > 2 || $errorScreenStore.urlToRedirect))}