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">
import { fly } from "svelte/transition";
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 cup from "../images/cup.png";
import reload from "../images/reload.png";
@ -39,10 +41,10 @@
{detailsStylized}{#if $errorScreenStore.type === "retry"}<div class="loading" />{/if}
</p>
{#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" />
{$errorScreenStore.buttonTitle}
</div>
</button>
{/if}
</div>
</main>
@ -130,12 +132,6 @@
.button {
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-size: 14px;
.reload {
@ -143,15 +139,5 @@
width: 22px;
}
}
.button:hover {
margin-bottom: 0;
margin-top: -5px;
padding: 18px 22px;
font-size: 16px;
.reload {
margin-top: -5px;
width: 24px;
}
}
}
</style>

View File

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

View File

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

View File

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

View File

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