fixes #49
This commit is contained in:
parent
895ec86ff6
commit
90b7b01e9a
@ -225,7 +225,6 @@ module.exports = function (Y/* :any */) {
|
||||
return
|
||||
}
|
||||
if (message.type === 'sync step 1') {
|
||||
// TODO: make transaction, stream the ops
|
||||
let conn = this
|
||||
let m = message
|
||||
this.y.db.requestTransaction(function *() {
|
||||
|
@ -80,8 +80,7 @@ module.exports = function (Y /* :any */) {
|
||||
return os.whenTransactionsFinished().then(function () {
|
||||
if (os.gc1.length > 0 || os.gc2.length > 0) {
|
||||
if (!os.y.isConnected()) {
|
||||
debugger
|
||||
console.log('gc should be empty when disconnected!')
|
||||
console.warn('gc should be empty when disconnected!')
|
||||
}
|
||||
return new Promise((resolve) => {
|
||||
os.requestTransaction(function * () {
|
||||
@ -379,24 +378,11 @@ module.exports = function (Y /* :any */) {
|
||||
}
|
||||
// called by a transaction when an operation is added
|
||||
* operationAdded (transaction, op) {
|
||||
if (op.struct === 'Delete') {
|
||||
throw new Error('this section shouldnt be entered anymore!')
|
||||
var target = yield* transaction.getOperation(op.target)
|
||||
if (target != null) {
|
||||
var type = transaction.store.initializedTypes[JSON.stringify(target.parent)]
|
||||
if (type != null) {
|
||||
yield* type._changed(transaction, {
|
||||
struct: 'Delete',
|
||||
target: op.target
|
||||
})
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// increase SS
|
||||
yield* transaction.updateState(op.id[0])
|
||||
|
||||
var opLen = op.content != null ? op.content.length : 1
|
||||
for (var i = 0; i < opLen; i++) {
|
||||
for (let 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]
|
||||
@ -431,7 +417,7 @@ module.exports = function (Y /* :any */) {
|
||||
// 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++) {
|
||||
for (let i = 0; i < len; i++) {
|
||||
var id = [startId[0], startId[1] + i]
|
||||
var opIsDeleted = yield* transaction.isDeleted(id)
|
||||
if (opIsDeleted) {
|
||||
@ -444,7 +430,6 @@ module.exports = function (Y /* :any */) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
whenTransactionsFinished () {
|
||||
if (this.transactionInProgress) {
|
||||
if (this.transactionsFinished == null) {
|
||||
|
@ -212,18 +212,11 @@ module.exports = function (Y/* :any */) {
|
||||
// reconnect left and set right of op
|
||||
if (op.left != null) {
|
||||
left = yield* this.getInsertion(op.left)
|
||||
// TODO: remove false!!
|
||||
if (false && op.content != null && left.content != null && left.id[0] === op.id[0] && left.id[1] + left.content.length === op.id[1] && left.originOf == null && left.deleted !== true && left.gc !== true) {
|
||||
// extend left
|
||||
left.content = left.content.concat(op.content)
|
||||
op = left
|
||||
} else {
|
||||
// link left
|
||||
op.right = left.right
|
||||
left.right = op.id
|
||||
|
||||
yield* this.setOperation(left)
|
||||
}
|
||||
} else {
|
||||
// set op.right from parent, if necessary
|
||||
op.right = op.parentSub ? parent.map[op.parentSub] || null : parent.start
|
||||
@ -268,7 +261,7 @@ module.exports = function (Y/* :any */) {
|
||||
}
|
||||
|
||||
// try to merge original op.left and op.origin
|
||||
for (var i = 0; i < tryToRemergeLater.length; i++) {
|
||||
for (let i = 0; i < tryToRemergeLater.length; i++) {
|
||||
var m = yield* this.getOperation(tryToRemergeLater[i])
|
||||
yield* this.tryCombineWithLeft(m)
|
||||
}
|
||||
|
@ -736,9 +736,7 @@ module.exports = function (Y/* :any */) {
|
||||
}
|
||||
if (this.store.forwardAppliedOperations) {
|
||||
var ops = []
|
||||
for (let c = del[1]; c < del[1] + del[2]; c++) {
|
||||
ops.push({struct: 'Delete', target: [d[0], c]}) // TODO: implement Delete with deletion length!
|
||||
}
|
||||
ops.push({struct: 'Delete', target: [d[0], d[1]], length: del[2]})
|
||||
this.store.y.connector.broadcastOps(ops)
|
||||
}
|
||||
}
|
||||
|
@ -298,8 +298,9 @@ module.exports = function (Y /* : any*/) {
|
||||
I tried to optimize this for performance, therefore no highlevel operations.
|
||||
*/
|
||||
class SmallLookupBuffer extends Store {
|
||||
constructor () {
|
||||
super(...arguments)
|
||||
constructor (arg) {
|
||||
// super(...arguments) -- do this when this is supported by stable nodejs
|
||||
super(arg)
|
||||
this.writeBuffer = createEmptyOpsArray(5)
|
||||
this.readBuffer = createEmptyOpsArray(10)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user