Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • sweng-group-15/yjs
1 result
Show changes
Commits on Source (3)
...@@ -351,13 +351,29 @@ module.exports = function (Y/* :any */) { ...@@ -351,13 +351,29 @@ module.exports = function (Y/* :any */) {
} }
}) })
*/ */
defer.resolve() defer.resolve(m.os && m.os.length > 0)
}) })
} else if (message.type === 'sync done') { } else if (message.type === 'sync done') {
var self = this var self = this
this.connections[sender].syncStep2.then(function () { this.connections[sender].syncStep2.then(function (resync) {
if (resync) {
const answer = {
type: 'sync check',
}
for (const uid in self.connections) {
if (uid !== sender) {
self.send(uid, answer)
}
}
}
self._setSyncedWith(sender) self._setSyncedWith(sender)
}) })
} else if (message.type === 'sync check') {
const conn = this.connections[sender]
if (conn != null && conn.isSynced) {
conn.isSynced = false
}
this.findNextSyncTarget()
} else if (message.type === 'update' && canWrite(auth)) { } else if (message.type === 'update' && canWrite(auth)) {
if (this.forwardToSyncingClients) { if (this.forwardToSyncingClients) {
for (var client of this.syncingClients) { for (var client of this.syncingClients) {
......
...@@ -165,7 +165,7 @@ module.exports = function (Y/* :any */) { ...@@ -165,7 +165,7 @@ module.exports = function (Y/* :any */) {
o = (o.right == null) ? null : yield* this.getOperation(o.right) o = (o.right == null) ? null : yield* this.getOperation(o.right)
} else { // left == null } else { // left == null
parent = yield* this.getOperation(op.parent) parent = yield* this.getOperation(op.parent)
let startId = op.parentSub ? parent.map[op.parentSub] : parent.start let startId = op.parentSub ? parent.map[op.parentSub] : (parent.struct == "Union" ? parent.union : parent.start)
start = startId == null ? null : yield* this.getOperation(startId) start = startId == null ? null : yield* this.getOperation(startId)
o = start o = start
} }
...@@ -223,7 +223,7 @@ module.exports = function (Y/* :any */) { ...@@ -223,7 +223,7 @@ module.exports = function (Y/* :any */) {
yield* this.setOperation(left) yield* this.setOperation(left)
} else { } else {
// set op.right from parent, if necessary // set op.right from parent, if necessary
op.right = op.parentSub ? parent.map[op.parentSub] || null : parent.start op.right = op.parentSub ? parent.map[op.parentSub] || null : (parent.struct == "Union" ? parent.union : parent.start)
} }
// reconnect right // reconnect right
if (op.right != null) { if (op.right != null) {
...@@ -256,6 +256,11 @@ module.exports = function (Y/* :any */) { ...@@ -256,6 +256,11 @@ module.exports = function (Y/* :any */) {
if (op.left != null) { if (op.left != null) {
yield* this.deleteOperation(op.id, 1, true) yield* this.deleteOperation(op.id, 1, true)
} }
} else if (parent.struct == "Union") {
if (left == null) {
parent.union = op.id
yield* this.setOperation(parent)
}
} else { } else {
if (right == null || left == null) { if (right == null || left == null) {
if (right == null) { if (right == null) {
......
...@@ -124,7 +124,7 @@ function Y (opts/* :YOptions */) /* :Promise<YConfig> */ { ...@@ -124,7 +124,7 @@ function Y (opts/* :YOptions */) /* :Promise<YConfig> */ {
else if (opts.connector == null) reject('You must specify a connector! (missing connector property)') else if (opts.connector == null) reject('You must specify a connector! (missing connector property)')
else if (opts.connector.name == null) reject('You must specify connector name! (missing connector.name property)') else if (opts.connector.name == null) reject('You must specify connector name! (missing connector.name property)')
else if (opts.db == null) reject('You must specify a database! (missing db property)') else if (opts.db == null) reject('You must specify a database! (missing db property)')
else if (opts.connector.name == null) reject('You must specify db name! (missing db.name property)') else if (opts.db.name == null) reject('You must specify db name! (missing db.name property)')
else { else {
opts = Y.utils.copyObject(opts) opts = Y.utils.copyObject(opts)
opts.connector = Y.utils.copyObject(opts.connector) opts.connector = Y.utils.copyObject(opts.connector)
......