Merge pull request #2075 from thecodingmachine/codeAPI

Refactoring Error Screen
This commit is contained in:
David Négrier
2022-04-22 16:52:43 +02:00
committed by GitHub
20 changed files with 651 additions and 184 deletions
+46
View File
@@ -0,0 +1,46 @@
import { z } from "zod";
/*
* WARNING! The original file is in /messages/JsonMessages.
* All other files are automatically copied from this file on container startup / build
*/
export const isErrorApiErrorData = z.object({
// @ts-ignore
type: z.literal("error"),
code: z.string(),
title: z.string(),
subtitle: z.string(),
details: z.string(),
image: z.string(),
});
export const isErrorApiRetryData = z.object({
type: z.literal("retry"),
code: z.string(),
title: z.string(),
subtitle: z.string(),
details: z.string(),
image: z.string(),
buttonTitle: z.optional(z.nullable(z.string())),
timeToRetry: z.number(),
canRetryManual: z.boolean(),
});
export const isErrorApiRedirectData = z.object({
type: z.literal("redirect"),
urlToRedirect: z.string(),
});
export const isErrorApiUnauthorizedData = z.object({
type: z.literal("unauthorized"),
});
export const isErrorApiData = z.discriminatedUnion("type", [
isErrorApiErrorData,
isErrorApiRetryData,
isErrorApiRedirectData,
isErrorApiUnauthorizedData,
]);
export type ErrorApiData = z.infer<typeof isErrorApiData>;
+20
View File
@@ -217,10 +217,29 @@ message UserLeftMessage {
int32 userId = 1;
}
/*
* ErrorMessage is only used to console.error the message in the front
*/
message ErrorMessage {
string message = 1;
}
/*
* ErrorScreenMessage is used to show the ErrorScreen in the front
*/
message ErrorScreenMessage {
string type = 1;
google.protobuf.StringValue code = 2;
google.protobuf.StringValue title = 3;
google.protobuf.StringValue subtitle = 4;
google.protobuf.StringValue details = 5;
google.protobuf.Int32Value timeToRetry = 6;
google.protobuf.BoolValue canRetryManual = 7;
google.protobuf.StringValue urlToRedirect = 8;
google.protobuf.StringValue buttonTitle = 9;
google.protobuf.StringValue image = 10;
}
message ItemStateMessage {
int32 itemId = 1;
string stateJson = 2;
@@ -332,6 +351,7 @@ message ServerToClientMessage {
FollowAbortMessage followAbortMessage = 23;
InvalidTextureMessage invalidTextureMessage = 24;
GroupUsersUpdateMessage groupUsersUpdateMessage = 25;
ErrorScreenMessage errorScreenMessage = 26;
}
}