Undo / redo on modified arrays leads to duplicated data

Hi, I posted about this issue in this thread.
In that case I was developing a simple collaborative Kanban board in which I can drag notes between different containers.
My solution was to identify duplications and avoid rendering them.
I identified duplications by giving IDs to everything, and having each note point to its container. Like this:

{
  "containers": {
    "1": {
      "name": "Doing",
      "noteIds": [
        "1",
        "2",
        "3" // Not rendered: note points to container "2"
      ]
    },
    "2": {
      "name": "Done",
      "noteIds": [
        "3",
        "3", // Not rendered: already appeared in this container
        "4"
      ]
    }
  },
  "notes": {
    "1": { "containerId": "1" },
    "2": { "containerId": "1" },
    "3": { "containerId": "2" },
    "4": { "containerId": "2" }
  }
}

Hope that helps.

1 Like