Use the same types.

mitja/return-results
Mitja Bezenšek 2024-04-26 15:55:53 +02:00
rodzic e2e9c50e03
commit 999a33d4ec
5 zmienionych plików z 8 dodań i 4 usunięć

Wyświetl plik

@ -2194,7 +2194,7 @@ export interface TLErrorBoundaryProps {
// @public (undocumented)
export type TLErrorEvent = {
type: 'max-shapes';
type: TLEditorErrorType;
value: [{
count: number;
name: string;

Wyświetl plik

@ -8520,7 +8520,7 @@ export class Editor extends EventEmitter<TLEventMap> {
function alertMaxShapes(editor: Editor, pageId = editor.getCurrentPageId()) {
const name = editor.getPage(pageId)!.name
editor.emit('error', {
type: 'max-shapes',
type: 'max-shapes-reached',
value: [{ name, pageId, count: MAX_SHAPES_PER_PAGE }],
})
}

Wyświetl plik

@ -22,6 +22,9 @@ export const EditorResult = {
},
}
// All errors
export type TLEditorErrorType = CreateShapeErrorType | (typeof READONLY_ROOM_ERROR)['type']
// General errors
/** @public */
export const READONLY_ROOM_ERROR = { type: 'readonly-room' as const, message: 'Room is readonly' }

Wyświetl plik

@ -1,10 +1,11 @@
import { HistoryEntry } from '@tldraw/store'
import { TLPageId, TLRecord, TLShapeId } from '@tldraw/tlschema'
import { TLEditorErrorType } from './editor-result-types'
import { TLEventInfo } from './event-types'
/** @public */
export type TLErrorEvent = {
type: 'max-shapes'
type: TLEditorErrorType
value: [{ name: string; pageId: TLPageId; count: number }]
}

Wyświetl plik

@ -9,7 +9,7 @@ export function useEditorEvents() {
useEffect(() => {
function handleMaxShapes(error: TLErrorEvent) {
if (error.type !== 'max-shapes') return
if (error.type !== 'max-shapes-reached') return
const [{ name, count }] = error.value
addToast({
title: 'Maximum Shapes Reached',