fix(canvas): align optimistic edge id typing with queue payloads

This commit is contained in:
2026-04-03 18:07:59 +02:00
parent af3cb47247
commit 2542748e82
2 changed files with 10 additions and 10 deletions

View File

@@ -489,7 +489,7 @@ function CanvasInner({ canvasId }: CanvasInnerProps) {
_id: tempEdgeId, _id: tempEdgeId,
_creationTime: Date.now(), _creationTime: Date.now(),
canvasId: args.canvasId, canvasId: args.canvasId,
sourceNodeId: args.sourceNodeId, sourceNodeId: args.sourceNodeId as Id<"nodes">,
targetNodeId: tempNodeId, targetNodeId: tempNodeId,
sourceHandle: args.sourceHandle, sourceHandle: args.sourceHandle,
targetHandle: args.targetHandle, targetHandle: args.targetHandle,
@@ -549,7 +549,7 @@ function CanvasInner({ canvasId }: CanvasInnerProps) {
_creationTime: Date.now(), _creationTime: Date.now(),
canvasId: args.canvasId, canvasId: args.canvasId,
sourceNodeId: tempNodeId, sourceNodeId: tempNodeId,
targetNodeId: args.targetNodeId, targetNodeId: args.targetNodeId as Id<"nodes">,
sourceHandle: args.sourceHandle, sourceHandle: args.sourceHandle,
targetHandle: args.targetHandle, targetHandle: args.targetHandle,
}; };
@@ -701,8 +701,8 @@ function CanvasInner({ canvasId }: CanvasInnerProps) {
const addOptimisticEdgeLocally = useCallback((args: { const addOptimisticEdgeLocally = useCallback((args: {
clientRequestId: string; clientRequestId: string;
sourceNodeId: Id<"nodes">; sourceNodeId: string;
targetNodeId: Id<"nodes">; targetNodeId: string;
sourceHandle?: string; sourceHandle?: string;
targetHandle?: string; targetHandle?: string;
}): Id<"edges"> => { }): Id<"edges"> => {

View File

@@ -30,7 +30,7 @@ export type CanvasSyncOpPayloadByType = {
parentId?: Id<"nodes">; parentId?: Id<"nodes">;
zIndex?: number; zIndex?: number;
clientRequestId: string; clientRequestId: string;
sourceNodeId: Id<"nodes">; sourceNodeId: string;
sourceHandle?: string; sourceHandle?: string;
targetHandle?: string; targetHandle?: string;
}; };
@@ -45,7 +45,7 @@ export type CanvasSyncOpPayloadByType = {
parentId?: Id<"nodes">; parentId?: Id<"nodes">;
zIndex?: number; zIndex?: number;
clientRequestId: string; clientRequestId: string;
targetNodeId: Id<"nodes">; targetNodeId: string;
sourceHandle?: string; sourceHandle?: string;
targetHandle?: string; targetHandle?: string;
}; };
@@ -334,7 +334,7 @@ function normalizeOp(raw: unknown): CanvasSyncOp | null {
: undefined, : undefined,
zIndex: typeof payload.zIndex === "number" ? payload.zIndex : undefined, zIndex: typeof payload.zIndex === "number" ? payload.zIndex : undefined,
clientRequestId: payload.clientRequestId, clientRequestId: payload.clientRequestId,
sourceNodeId: payload.sourceNodeId as Id<"nodes">, sourceNodeId: payload.sourceNodeId,
sourceHandle: sourceHandle:
typeof payload.sourceHandle === "string" typeof payload.sourceHandle === "string"
? payload.sourceHandle ? payload.sourceHandle
@@ -381,7 +381,7 @@ function normalizeOp(raw: unknown): CanvasSyncOp | null {
: undefined, : undefined,
zIndex: typeof payload.zIndex === "number" ? payload.zIndex : undefined, zIndex: typeof payload.zIndex === "number" ? payload.zIndex : undefined,
clientRequestId: payload.clientRequestId, clientRequestId: payload.clientRequestId,
targetNodeId: payload.targetNodeId as Id<"nodes">, targetNodeId: payload.targetNodeId,
sourceHandle: sourceHandle:
typeof payload.sourceHandle === "string" typeof payload.sourceHandle === "string"
? payload.sourceHandle ? payload.sourceHandle
@@ -834,7 +834,7 @@ function remapNodeIdInPayload(
changed = true; changed = true;
} }
if (next.sourceNodeId === fromNodeId) { if (next.sourceNodeId === fromNodeId) {
next.sourceNodeId = toNodeId as Id<"nodes">; next.sourceNodeId = toNodeId;
changed = true; changed = true;
} }
if (changed) { if (changed) {
@@ -849,7 +849,7 @@ function remapNodeIdInPayload(
changed = true; changed = true;
} }
if (next.targetNodeId === fromNodeId) { if (next.targetNodeId === fromNodeId) {
next.targetNodeId = toNodeId as Id<"nodes">; next.targetNodeId = toNodeId;
changed = true; changed = true;
} }
if (changed) { if (changed) {