fixed several sync issues

This commit is contained in:
Kevin Jahns
2016-11-04 11:42:50 +01:00
parent 93c23ddc09
commit cd0cddaf35
3 changed files with 19 additions and 20 deletions

View File

@@ -144,11 +144,6 @@ module.exports = function (Y/* :any */) {
this.whenSyncedListeners.push(f)
}
}
/*
returns false, if there is no sync target
true otherwise
*/
findNextSyncTarget () {
if (this.y == null) {
debugger
@@ -179,16 +174,20 @@ module.exports = function (Y/* :any */) {
})
})
} else {
this.y.db.requestTransaction(function *() {
// it is crucial that isSynced is set at the time garbageCollectAfterSync is called
conn.isSynced = true
yield* this.garbageCollectAfterSync()
// call whensynced listeners
for (var f of conn.whenSyncedListeners) {
f()
}
conn.whenSyncedListeners = []
})
if (!conn.isSynced) {
this.y.db.requestTransaction(function *() {
if (!conn.isSynced) {
// it is crucial that isSynced is set at the time garbageCollectAfterSync is called
conn.isSynced = true
yield* this.garbageCollectAfterSync()
// call whensynced listeners
for (var f of conn.whenSyncedListeners) {
f()
}
conn.whenSyncedListeners = []
}
})
}
}
}
send (uid, message) {