What you really seem to want is a “move” feature in Yjs (that’s something that I’ve been working on). “moving of elements” will guarantee that there will be only one identity of each element. Moving an element twice shouldn’t result in duplication.
This issue has also been discussed in:
Now, this doesn’t solve your issue because the new move feature will not (yet) support moving between arrays. One simple solution, that I also suggested in the thread, is to have some kind of “cleanup” function that remove duplicate elements. It should consistently remove the same element (e.g. always the last element) to ensure that all clients end up with the same content without deleting the element entirely. A case you want to prevent is that user A cleans up the first duplicate, and user B cleans up the second duplicate.
Yeah that sounds exactly like what I need. A move function would actually solve a ton of issues, so very exciting that it’s already in the works!
Going to assume it’s this PR
Just to clarify, is it considered the re-parenting if you’re moving from one array to another inside the same ymap?
Which would be the not yet functionality, if so then yeah this wouldn’t really do much for us yet until you can move between arrays.
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: