How do you call undo from code instead of ctrl - z, contextmenu, or button?

Currently, I have developed a real-time editing system that makes the changes on one machine reflect on another user’s machine and almost everything works flawlessly. I am, however, running into issues with undo and redo. Here are the steps that I am following:

  1. First user changes the diagram.

  2. The changes are reflected on diagram of the second user (this works).

  3. First user undoes or redoes changes to the diagram.

  4. Second user should see the undone or redone changes (this is not working). If the second user uses ctrl+z, ctrl+y, or the contextmenu, it undoes or redoes the first user’s change. I am using the following code but this doesn’t seem to work. I know it is calling the code because I have replaced undo() with deleteSelection() and that works.

    data.origin == 'diagram-undo' ? fileDiagram.commandHandler.undo() : fileDiagram.commandHandler.redo();

Long story short, how do I call the undo stack inside of a function?

Call methods on UndoManager:
And you can look at the history there too.

But that is exactly what CommandHandler.undo calls, so I don’t see how that will help you.

Thanks! I think that this is a coding error on my part. It looks that I need to undo twice. Apparently, two changes are made instead of one and I need to diagnose this. Sorry for wasting your time. I do appreciate you pointing me to find the history though.