yjs / y-indexeddb

IndexedDB database adapter for Yjs
https://docs.yjs.dev/ecosystem/database-provider/y-indexeddb
Other
196 stars 30 forks source link

array insert happens twice on receiving end #2

Closed lukebarlow closed 7 years ago

lukebarlow commented 7 years ago

Steps to reproduce : Set up a Y object in two browsers, using the following configuration, and open the page twice, with two windows of the same browser.

Y({
  db: {
    name: 'indexeddb'
  },
  connector: {
    name: 'websockets-client',
    room: 'test'
  },
  share: {
    state : 'Map'
  }
}).then((y) => { window.y = y })

In window A, type var a = y.set('list', Y.Array);a.push([1])

Now, in window B, inspect the result with console.log(y.get('list').toArray(). The result is [ 1, 1 ], rather than the expected [1]. This doesn't occur when the receiving window is in a separate browser, or when the two parts of setting the list var a = y.set('list', Y.Array) and populating it a.push([1]) are executed with a pause inbetween.

dmonad commented 7 years ago

Fixed in y-indexeddb@v8.1.4

lukebarlow commented 7 years ago

I'm still seeing the issue

dmonad commented 7 years ago

Your are right. I only fixed it for chrome. It's still not working in Firefox

dmonad commented 7 years ago

I found a better solution now. You have to update to update y-array@10.0.4 and y-map@10.0.3 (same issue could happen in y-map)

lukebarlow commented 7 years ago

Brilliant. Yes, works now

On Wed, Oct 5, 2016 at 12:50 AM Kevin Jahns notifications@github.com wrote:

I found a better solution now. You have to update to update y-array@10.0.4 and y-map@10.0.3 (same issue could happen in y-map)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/y-js/y-indexeddb/issues/2#issuecomment-251546162, or mute the thread https://github.com/notifications/unsubscribe-auth/AAj-NDuGiJ8c5Sx6dyKiGEhCQ2kP59rhks5qwuZegaJpZM4KNnPo .