From 0914438002896b73c2e3d52b7dadb29819061121 Mon Sep 17 00:00:00 2001 From: Bill Cook Date: Fri, 6 Dec 2024 11:39:19 +0900 Subject: [PATCH] feedback(ui): updated conditionals for handleWorkFlow Redo and Undo --- ui/src/lib/yjs/useYjsStore.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ui/src/lib/yjs/useYjsStore.ts b/ui/src/lib/yjs/useYjsStore.ts index bce57ac49..6094516bb 100644 --- a/ui/src/lib/yjs/useYjsStore.ts +++ b/ui/src/lib/yjs/useYjsStore.ts @@ -37,17 +37,18 @@ export default ({ const { createDeployment, useUpdateDeployment } = useDeployment(); const handleWorkflowUndo = useCallback(() => { - if (undoManager?.undoStack && undoManager.undoStack.length > 0) { + const stackLength = undoManager?.undoStack?.length ?? 0; + if (stackLength > 0) { undoManager?.undo(); } }, [undoManager]); const handleWorkflowRedo = useCallback(() => { - if (undoManager?.redoStack && undoManager.redoStack.length > 0) { + const stackLength = undoManager?.redoStack?.length ?? 0; + if (stackLength > 0) { undoManager?.redo(); } }, [undoManager]); - const canUndo = useMemo(() => { const stackLength = undoManager?.undoStack?.length ?? 0; return stackLength > 0;