Hi there,
Is there an elegant way of handling undo / redo when someone else has modified the data you’re about to undo / redo?
Here’s a couple examples to show what I mean
Example 1: Text
Using https://tiptap.dev
Initial data: “”
Step 1 - User A: “” → "ABCDEF"
Step 2 - User B: “ABCDEF” → “ADDDDF”
Step 3 - User A UNDO: “ADDDDF” → "DDDD"
Now since this is text this is probably fine, but when you’re modifying arrays this can super easily put your data in an invalid state.
Example 2: multiple arrays
Initial data:
const arr1 = [1,2,3,4,5,6]
const arr2 = []
const arr3 = []
Step 1 - User A:
const arr1 = []
const arr2 = [1,2,3]
const arr3 = [4,5,6]
Step 2 - User B:
const arr1 = []
const arr2 = [1,2,6]
const arr3 = [4,5,3]
Step 3 - User A UNDO:
const arr1 = [1,2,3,4,5,6]
const arr2 = [6]
const arr3 = [3]
3 and 6 are now duplicated, which in my case breaks the data.
Has anyone run into a similar problem or know how one would go about solving this?
Thanks in advance!