From 51e20fb9c75e6db269c06e1f3a5af21a48a19d2a Mon Sep 17 00:00:00 2001 From: Kevin Jahns <kevin.jahns@rwth-aachen.de> Date: Mon, 12 Oct 2015 15:59:22 +0200 Subject: [PATCH] fixed some example issues --- gulpfile.js | 4 ++++ src/Connectors/WebRTC.js | 3 +++ src/OperationStore.js | 8 ++++---- src/OperationStores/Memory.js | 4 ++++ 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 2efc75fe..5f947329 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -140,6 +140,10 @@ gulp.task('dev:browser', ['build:test'], function () { .pipe(jasmineBrowser.server({port: options.testport})) }) +gulp.task('dev:deploy', ['build:deploy'], function () { + gulp.watch('src/**/*.js', ['build:deploy']) +}) + gulp.task('dev', ['build:test'], function () { gulp.start('dev:browser') gulp.start('dev:node') diff --git a/src/Connectors/WebRTC.js b/src/Connectors/WebRTC.js index acf9aa86..954aa0d0 100644 --- a/src/Connectors/WebRTC.js +++ b/src/Connectors/WebRTC.js @@ -83,6 +83,9 @@ class WebRTC extends Y.AbstractConnector { broadcast (message) { this.swr.sendDirectlyToAll('simplewebrtc', 'yjs', message) } + isDisconnected () { + return false + } } Y.WebRTC = WebRTC diff --git a/src/OperationStore.js b/src/OperationStore.js index d904e4c0..1127b934 100644 --- a/src/OperationStore.js +++ b/src/OperationStore.js @@ -305,9 +305,9 @@ class AbstractOperationStore { } os.gc2 = os.gc1 os.gc1 = [] - if (os.gcTimeout > 0) { - os.gcInterval = setTimeout(garbageCollect, os.gcTimeout) - } + } + if (os.gcTimeout > 0) { + os.gcInterval = setTimeout(garbageCollect, os.gcTimeout) } resolve() }) @@ -490,7 +490,7 @@ class AbstractOperationStore { * tryExecute (op) { if (op.struct === 'Delete') { yield* Y.Struct.Delete.execute.call(this, op) - } else if ((yield* this.getOperation(op.id)) == null) { + } else if ((yield* this.getOperation(op.id)) == null && !this.store.ds.isGarbageCollected(op.id)) { yield* Y.Struct[op.struct].execute.call(this, op) var next = yield* this.addOperation(op) yield* this.store.operationAdded(this, op, next) diff --git a/src/OperationStores/Memory.js b/src/OperationStores/Memory.js index 38a584c7..743c59d4 100644 --- a/src/OperationStores/Memory.js +++ b/src/OperationStores/Memory.js @@ -10,6 +10,10 @@ class DeleteStore extends Y.utils.RBTree { var n = this.findNodeWithUpperBound(id) return n !== null && n.val.id[0] === id[0] && id[1] < n.val.id[1] + n.val.len } + isGarbageCollected (id) { + var n = this.findNodeWithUpperBound(id) + return n !== null && n.val.id[0] === id[0] && id[1] < n.val.id[1] + n.val.len && n.val.gc + } /* Mark an operation as deleted&gc'd -- GitLab