Porównaj commity

...

4 Commity

Autor SHA1 Wiadomość Data
Mime Čuvalo cbe94b660a
feedback 2024-04-23 14:13:31 +01:00
Mime Čuvalo f8de842439
nit 2024-04-23 10:35:20 +01:00
Mime Čuvalo 72e06ba206
enum -> const 2024-04-23 09:59:33 +01:00
Mime Čuvalo 0342ae76a2
add closeCode test in socket adapter 2024-04-23 09:55:21 +01:00
5 zmienionych plików z 23 dodań i 15 usunięć

Wyświetl plik

@ -1,4 +1,5 @@
import { Link } from 'react-router-dom'
import { isInIframe } from '../../utils/iFrame'
export function ErrorPage({
icon,
@ -19,9 +20,7 @@ export function ErrorPage({
<p>{messages.para1}</p>
{messages.para2 && <p>{messages.para2}</p>}
</div>
<Link to={'/'}>
<a>Take me home.</a>
</Link>
<Link to={'/'}>{isInIframe() ? 'Open tldraw.' : 'Back to tldraw.'}</Link>
</div>
</div>
)

Wyświetl plik

@ -1,9 +1,11 @@
import { TLIncompatibilityReason } from '@tldraw/tlsync'
import { ErrorScreen, exhaustiveSwitchError } from 'tldraw'
import { exhaustiveSwitchError } from 'tldraw'
import { RemoteSyncError } from '../utils/remote-sync/remote-sync'
import { ErrorPage } from './ErrorPage/ErrorPage'
export function StoreErrorScreen({ error }: { error: Error }) {
let message = 'Could not connect to server.'
let header = 'Could not connect to server.'
let message = ''
if (error instanceof RemoteSyncError) {
switch (error.reason) {
@ -27,8 +29,8 @@ export function StoreErrorScreen({ error }: { error: Error }) {
break
}
case TLIncompatibilityReason.RoomNotFound: {
message =
'The room you are trying to connect to does not exist. Please check the URL and try again. If the problem persists contact the system administrator.'
header = 'Room not found'
message = 'The room you are trying to connect to does not exist.'
break
}
default:
@ -36,9 +38,5 @@ export function StoreErrorScreen({ error }: { error: Error }) {
}
}
return (
<div className="tldraw__editor tl-container">
<ErrorScreen>{message}</ErrorScreen>
</div>
)
return <ErrorPage icon messages={{ header, para1: message }} />
}

Wyświetl plik

@ -174,6 +174,16 @@ describe(ClientWebSocketAdapter, () => {
expect(onStatusChange).toHaveBeenCalledWith('error', undefined)
})
it('signals the correct closeCode when a room is not found', async () => {
const onStatusChange = jest.fn()
adapter.onStatusChange(onStatusChange)
await waitFor(() => adapter._ws?.readyState === WebSocket.OPEN)
adapter._ws!.onclose?.({ code: 4099 } as any)
expect(onStatusChange).toHaveBeenCalledWith('error', 4099)
})
it('signals status changes while restarting', async () => {
const onStatusChange = jest.fn()
await waitFor(() => adapter._ws?.readyState === WebSocket.OPEN)

Wyświetl plik

@ -183,6 +183,7 @@ a {
font-weight: 500;
color: var(--text-color-2);
padding: 12px 4px;
text-decoration: underline;
}
/* ------------------ Board history ----------------- */

Wyświetl plik

@ -31,9 +31,9 @@ type SubscribingFn<T> = (cb: (val: T) => void) => () => void
*
* @public
*/
export enum TLCloseEventCode {
NOT_FOUND = 4099,
}
export const TLCloseEventCode = {
NOT_FOUND: 4099,
} as const
/** @public */
export type TLPersistentClientSocketStatus = 'online' | 'offline' | 'error'