#Undo event

1 messages · Page 1 of 1 (latest)

half gulch
#

Hi Netero. I didn't get the issue you have while adding the node/edge back. What do you mean by it throws undefined value? You would simply add the node/edge back in the appropriate state in case of undoing a delete action as you said. It shouldn't be an issue.

half gulch
#

Hmn. At the end of the day, you still have to mutate the whole nodes or edges array state when you undo or redo.

#

What is the actual problem you are facing when you add the node or edge back to the array state on undoing a delete action? You said it throws undefined value. I didnt get it?

half gulch
#

You are storing the node object in some history stack when you delete a node(use the filter method to remove that node from the nodes state) and then when you undo you add that node object back to the nodes array state?

#

Can you share the undo function? Also the function in which you update your history stack when you delete a node?

half gulch
#

Kindly share the setUndoAction function as well

half gulch
#

In the handleUndo function, you are calling the setUndoAction function in case of DELETE. I am asking you to share its code

 case "DELETE_NODE":
        if (actionHistory.nodeData && actionHistory.edgeData) {
          setUndoAction(); // <--- THIS ONE
        } else {
          console.error("actionHistory nodeData or edgeData is not found.");
        }
        break;
#

In this function, why arent you adding the node and edges you saved, back into the nodes and edges state?