Review of changes asked to make code cleaner

This commit is contained in:
CEC 2022-04-13 16:58:03 +02:00
parent bf40bd2f3b
commit 26dc8dbbaf
5 changed files with 26 additions and 34 deletions

View File

@ -1,8 +1,10 @@
<script lang="ts"> <script lang="ts">
import { fly } from "svelte/transition"; import { fly } from "svelte/transition";
import { errorScreenStore } from "../../Stores/ErrorScreenStore"; import { errorScreenStore } from "../../Stores/ErrorScreenStore";
import { gameManager } from "../../Phaser/Game/GameManager";
import logo from "../images/logo-min-white.png"; import logoImg from "../images/logo-min-white.png";
let logo = gameManager?.currentStartedRoom?.loginSceneLogo ?? logoImg;
import error from "../images/error.png"; import error from "../images/error.png";
import cup from "../images/cup.png"; import cup from "../images/cup.png";
import reload from "../images/reload.png"; import reload from "../images/reload.png";
@ -39,10 +41,10 @@
{detailsStylized}{#if $errorScreenStore.type === "retry"}<div class="loading" />{/if} {detailsStylized}{#if $errorScreenStore.type === "retry"}<div class="loading" />{/if}
</p> </p>
{#if ($errorScreenStore.type === "retry" && $errorScreenStore.canRetryManual) || ($errorScreenStore.type === "redirect" && (window.history.length > 2 || $errorScreenStore.urlToRedirect))} {#if ($errorScreenStore.type === "retry" && $errorScreenStore.canRetryManual) || ($errorScreenStore.type === "redirect" && (window.history.length > 2 || $errorScreenStore.urlToRedirect))}
<div class="button" on:click={click}> <button type="button" class="nes-btn is-primary 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> </button>
{/if} {/if}
</div> </div>
</main> </main>
@ -130,12 +132,6 @@
.button { .button {
cursor: pointer; cursor: pointer;
background-image: url("../images/button-large.png");
background-position: center;
background-repeat: no-repeat;
background-size: contain;
padding: 16px 20px;
margin-bottom: 2px;
font-family: "Press Start 2P"; font-family: "Press Start 2P";
font-size: 14px; font-size: 14px;
.reload { .reload {
@ -143,15 +139,5 @@
width: 22px; width: 22px;
} }
} }
.button:hover {
margin-bottom: 0;
margin-top: -5px;
padding: 18px 22px;
font-size: 16px;
.reload {
margin-top: -5px;
width: 24px;
}
}
} }
</style> </style>

View File

@ -25,7 +25,7 @@ import {
TokenExpiredMessage, TokenExpiredMessage,
WorldConnexionMessage, WorldConnexionMessage,
ErrorMessage as ErrorMessageTsProto, ErrorMessage as ErrorMessageTsProto,
ErrorV2Message as ErrorV2MessageTsProto, ErrorScreenMessage as ErrorScreenMessageTsProto,
UserMovedMessage as UserMovedMessageTsProto, UserMovedMessage as UserMovedMessageTsProto,
GroupUpdateMessage as GroupUpdateMessageTsProto, GroupUpdateMessage as GroupUpdateMessageTsProto,
GroupDeleteMessage as GroupDeleteMessageTsProto, GroupDeleteMessage as GroupDeleteMessageTsProto,
@ -64,8 +64,8 @@ export class RoomConnection implements RoomConnection {
private readonly _errorMessageStream = new Subject<ErrorMessageTsProto>(); private readonly _errorMessageStream = new Subject<ErrorMessageTsProto>();
public readonly errorMessageStream = this._errorMessageStream.asObservable(); public readonly errorMessageStream = this._errorMessageStream.asObservable();
private readonly _errorV2MessageStream = new Subject<ErrorV2MessageTsProto>(); private readonly _errorScreenMessageStream = new Subject<ErrorScreenMessageTsProto>();
public readonly errorV2MessageStream = this._errorV2MessageStream.asObservable(); public readonly errorScreenMessageStream = this._errorScreenMessageStream.asObservable();
private readonly _roomJoinedMessageStream = new Subject<{ private readonly _roomJoinedMessageStream = new Subject<{
connection: RoomConnection; connection: RoomConnection;
@ -482,11 +482,11 @@ export class RoomConnection implements RoomConnection {
console.error("An error occurred server side: " + message.errorMessage.message); console.error("An error occurred server side: " + message.errorMessage.message);
break; break;
} }
case "errorV2Message": { case "errorScreenMessage": {
this._errorV2MessageStream.next(message.errorV2Message); this._errorScreenMessageStream.next(message.errorScreenMessage);
if (message.errorV2Message.code !== "retry") this.closed = true; if (message.errorScreenMessage.code !== "retry") this.closed = true;
console.error("An error occurred server side: " + message.errorV2Message.code); console.error("An error occurred server side: " + message.errorScreenMessage.code);
errorScreenStore.setError(message.errorV2Message as unknown as WAError); errorScreenStore.setError(message.errorScreenMessage as WAError);
break; break;
} }
default: { default: {

View File

@ -214,11 +214,17 @@ message UserLeftMessage {
int32 userId = 1; int32 userId = 1;
} }
/*
* ErrorMessage is only used to console.error the message in the front
*/
message ErrorMessage { message ErrorMessage {
string message = 1; string message = 1;
} }
message ErrorV2Message { /*
* ErrorScreenMessage is used to show the ErrorScreen in the front
*/
message ErrorScreenMessage {
string type = 1; string type = 1;
string code = 2; string code = 2;
string title = 3; string title = 3;
@ -341,7 +347,7 @@ message ServerToClientMessage {
FollowAbortMessage followAbortMessage = 23; FollowAbortMessage followAbortMessage = 23;
InvalidTextureMessage invalidTextureMessage = 24; InvalidTextureMessage invalidTextureMessage = 24;
GroupUsersUpdateMessage groupUsersUpdateMessage = 25; GroupUsersUpdateMessage groupUsersUpdateMessage = 25;
ErrorV2Message errorV2Message = 26; ErrorScreenMessage errorScreenMessage = 26;
} }
} }

View File

@ -486,7 +486,7 @@ export class IoSocketController {
} else if (ws.reason === "textureInvalid") { } else if (ws.reason === "textureInvalid") {
socketManager.emitInvalidTextureMessage(ws); socketManager.emitInvalidTextureMessage(ws);
} else if (ws.reason === "error") { } else if (ws.reason === "error") {
socketManager.emitErrorV2Message( socketManager.emitErrorScreenMessage(
ws, ws,
ws.error.type, ws.error.type,
ws.error.code, ws.error.code,

View File

@ -40,7 +40,7 @@ import {
PlayerDetailsUpdatedMessage, PlayerDetailsUpdatedMessage,
LockGroupPromptMessage, LockGroupPromptMessage,
InvalidTextureMessage, InvalidTextureMessage,
ErrorV2Message, ErrorScreenMessage,
} from "../Messages/generated/messages_pb"; } from "../Messages/generated/messages_pb";
import { ProtobufUtils } from "../Model/Websocket/ProtobufUtils"; import { ProtobufUtils } from "../Model/Websocket/ProtobufUtils";
import { ADMIN_API_URL, JITSI_ISS, JITSI_URL, SECRET_JITSI_KEY } from "../Enum/EnvironmentVariable"; import { ADMIN_API_URL, JITSI_ISS, JITSI_URL, SECRET_JITSI_KEY } from "../Enum/EnvironmentVariable";
@ -644,7 +644,7 @@ export class SocketManager implements ZoneEventListener {
client.send(serverToClientMessage.serializeBinary().buffer, true); client.send(serverToClientMessage.serializeBinary().buffer, true);
} }
public emitErrorV2Message( public emitErrorScreenMessage(
client: compressors.WebSocket, client: compressors.WebSocket,
type: string, type: string,
code: string, code: string,
@ -656,7 +656,7 @@ export class SocketManager implements ZoneEventListener {
urlToRedirect: string, urlToRedirect: string,
buttonTitle: string buttonTitle: string
) { ) {
const errorMessage = new ErrorV2Message(); const errorMessage = new ErrorScreenMessage();
errorMessage.setType(type); errorMessage.setType(type);
errorMessage.setCode(code); errorMessage.setCode(code);
errorMessage.setTitle(title); errorMessage.setTitle(title);
@ -668,7 +668,7 @@ export class SocketManager implements ZoneEventListener {
errorMessage.setButtontitle(buttonTitle); errorMessage.setButtontitle(buttonTitle);
const serverToClientMessage = new ServerToClientMessage(); const serverToClientMessage = new ServerToClientMessage();
serverToClientMessage.setErrorv2message(errorMessage); serverToClientMessage.setErrorscreenmessage(errorMessage);
//if (!client.disconnecting) { //if (!client.disconnecting) {
client.send(serverToClientMessage.serializeBinary().buffer, true); client.send(serverToClientMessage.serializeBinary().buffer, true);