fix(striker-ui): clean up vnc error messages

This commit is contained in:
Tsu-ba-me 2024-05-22 01:24:25 -04:00
parent a477cc54f7
commit 99f7fd6498

View File

@ -63,13 +63,15 @@ const FullSize: FC<FullSizeProps> = ({
Partial<RfbConnectArgs> | undefined Partial<RfbConnectArgs> | undefined
>(undefined); >(undefined);
const [vncConnecting, setVncConnecting] = useState<boolean>(false); const [vncConnecting, setVncConnecting] = useState<boolean>(false);
const [vncError, setVncError] = useState<boolean>(false); const [vncError, setVncError] = useState<boolean>(false);
const [vncClientErrorMessage, setVncClientErrorMessage] = useState< const [vncWsErrorMessage, setVncWsErrorMessage] = useState<
string | undefined string | undefined
>(); >();
const [vncApiErrorMessage, setVncApiErrorMessage] = useState< const [vncApiErrorMessage, setVncApiErrorMessage] = useState<
string | undefined string | undefined
>(); >();
const [vncReconnectTimer, setVncReconnectTimer] = useState<number>( const [vncReconnectTimer, setVncReconnectTimer] = useState<number>(
vncReconnectTimerStart, vncReconnectTimerStart,
); );
@ -162,7 +164,11 @@ const FullSize: FC<FullSizeProps> = ({
const wsCloseEventHandler = useCallback( const wsCloseEventHandler = useCallback(
(event?: WebsockCloseEvent): void => { (event?: WebsockCloseEvent): void => {
if (!event) return; if (!event) {
setVncWsErrorMessage(undefined);
return;
}
const { code: wscode, reason } = event; const { code: wscode, reason } = event;
@ -172,13 +178,17 @@ const FullSize: FC<FullSizeProps> = ({
clientmsg += `, ${reason}`; clientmsg += `, ${reason}`;
} }
setVncClientErrorMessage(clientmsg); setVncWsErrorMessage(clientmsg);
const vncerror = buildCookieJar()[ const vncerror = buildCookieJar()[
`suiapi.vncerror.${serverUUID}` `suiapi.vncerror.${serverUUID}`
] as APIError; ] as APIError;
if (!vncerror) return; if (!vncerror) {
setVncApiErrorMessage(undefined);
return;
}
const { code: apicode, message } = vncerror; const { code: apicode, message } = vncerror;
@ -337,7 +347,7 @@ const FullSize: FC<FullSizeProps> = ({
<> <>
<HeaderText>Can&apos;t connect to the server.</HeaderText> <HeaderText>Can&apos;t connect to the server.</HeaderText>
<BodyText>{vncApiErrorMessage}</BodyText> <BodyText>{vncApiErrorMessage}</BodyText>
<BodyText>{vncClientErrorMessage}</BodyText> <BodyText>{vncWsErrorMessage}</BodyText>
<HeaderText mt=".5em"> <HeaderText mt=".5em">
Retrying in {vncReconnectTimer}. Retrying in {vncReconnectTimer}.
</HeaderText> </HeaderText>