fixed some old todos, fixed some cases related to "content is an array"

This commit is contained in:
Kevin Jahns
2016-04-12 16:18:05 +02:00
parent 20321c8a7d
commit a7f845f553
2 changed files with 53 additions and 30 deletions

View File

@@ -359,16 +359,19 @@ module.exports = function (Y /* :any */) {
// increase SS
yield* transaction.updateState(op.id[0])
// notify whenOperation listeners (by id)
var sid = JSON.stringify(op.id)
var l = this.listenersById[sid]
delete this.listenersById[sid]
if (l != null) {
for (var key in l) {
var listener = l[key]
if (--listener.missing === 0) {
this.whenOperationsExist([], listener.op)
var opLen = op.content != null ? op.content.length : 1
for (var i = 0; i < opLen; i++) {
// notify whenOperation listeners (by id)
var sid = JSON.stringify([op.id[0], op.id[1] + i])
var l = this.listenersById[sid]
delete this.listenersById[sid]
if (l != null) {
for (var key in l) {
var listener = l[key]
if (--listener.missing === 0) {
this.whenOperationsExist([], listener.op)
}
}
}
}
@@ -391,8 +394,9 @@ module.exports = function (Y /* :any */) {
if (!op.deleted) {
// Delete if DS says this is actually deleted
var len = op.content != null ? op.content.length : 1
var startId = op.id // You must not use op.id in the following loop, because op will change when deleted
for (var i = 0; i < len; i++) {
var id = [op.id[0], op.id[1] + i]
var id = [startId[0], startId[1] + i]
var opIsDeleted = yield* transaction.isDeleted(id)
if (opIsDeleted) {
var delop = {