fixed late join issues, and null on event
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
send_ = (function(_this) {
|
||||
return function(o) {
|
||||
var conn, conn_id, _ref, _results;
|
||||
if (o.uid.creator === _this.HB.getUserId() && (typeof o.uid.op_number !== "string")) {
|
||||
if (o.creator === _this.HB.getUserId() && (typeof o.uid.op_number !== "string") && o.uid.sync) {
|
||||
_ref = _this.connections;
|
||||
_results = [];
|
||||
for (conn_id in _ref) {
|
||||
@@ -71,7 +71,7 @@
|
||||
|
||||
} else if (data.HB != null) {
|
||||
initialized_me = true;
|
||||
_this.engine.applyOpsCheckDouble(data.HB);
|
||||
_this.engine.applyOpsCheckDouble(data.HB, data.state_vector);
|
||||
return conn.send({
|
||||
conns: _this.getAllConnectionIds()
|
||||
});
|
||||
@@ -88,7 +88,8 @@
|
||||
} else if (data.state_vector != null) {
|
||||
if (!initialized_him) {
|
||||
conn.send({
|
||||
HB: _this.yatta.getHistoryBuffer()._encode(data.state_vector)
|
||||
HB: _this.yatta.getHistoryBuffer()._encode(data.state_vector),
|
||||
state_vector: _this.yatta.HB.getOperationCounter()
|
||||
});
|
||||
return initialized_him = true;
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -38,18 +38,17 @@
|
||||
return this.tryUnprocessed();
|
||||
};
|
||||
|
||||
Engine.prototype.applyOpsCheckDouble = function(ops_json) {
|
||||
var o, _i, _len, _results;
|
||||
_results = [];
|
||||
Engine.prototype.applyOpsCheckDouble = function(ops_json, state_vector) {
|
||||
var o, _i, _len;
|
||||
for (_i = 0, _len = ops_json.length; _i < _len; _i++) {
|
||||
o = ops_json[_i];
|
||||
if (this.HB.getOperation(o.uid) == null) {
|
||||
_results.push(this.applyOp(o));
|
||||
} else {
|
||||
_results.push(void 0);
|
||||
this.applyOp(o);
|
||||
}
|
||||
}
|
||||
return _results;
|
||||
if (state_vector != null) {
|
||||
return this.HB.renewStateVector(state_vector);
|
||||
}
|
||||
};
|
||||
|
||||
Engine.prototype.applyOps = function(ops_json) {
|
||||
@@ -83,7 +82,9 @@
|
||||
_ref = this.unprocessed_ops;
|
||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||
op = _ref[_i];
|
||||
if (!op.execute()) {
|
||||
if (this.HB.getOperation(op.getUid()) != null) {
|
||||
|
||||
} else if (!op.execute()) {
|
||||
unprocessed.push(op);
|
||||
} else {
|
||||
this.HB.addOperation(op);
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -93,6 +93,17 @@
|
||||
}
|
||||
};
|
||||
|
||||
HistoryBuffer.prototype.renewOperationCounter = function(state_vector) {
|
||||
var key, value;
|
||||
for (key in state_vector) {
|
||||
value = state_vector[key];
|
||||
if (this.operation_counter[key] < value) {
|
||||
this.operation_counter[key] = value;
|
||||
}
|
||||
}
|
||||
return void 0;
|
||||
};
|
||||
|
||||
HistoryBuffer.prototype._encode = function(state_vector) {
|
||||
var json, o, o_json, o_next, o_number, o_prev, u_name, unknown, user, _ref;
|
||||
if (state_vector == null) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -222,7 +222,9 @@
|
||||
this.deleted_by = [];
|
||||
}
|
||||
if ((this.parent != null) && !this.isDeleted()) {
|
||||
this.parent.callEvent("delete", this, o);
|
||||
if (o != null) {
|
||||
this.parent.callEvent("delete", this, o);
|
||||
}
|
||||
}
|
||||
if (o != null) {
|
||||
this.deleted_by.push(o);
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -174,16 +174,12 @@
|
||||
WordType.prototype.setReplaceManager = function(op) {
|
||||
this.saveOperation('replace_manager', op);
|
||||
this.validateSavedOperations();
|
||||
this.on('insert', (function(_this) {
|
||||
return function(event, ins) {
|
||||
var _ref;
|
||||
return (_ref = _this.replace_manager) != null ? _ref.forwardEvent(_this, 'change', ins) : void 0;
|
||||
};
|
||||
})(this));
|
||||
this.on('insert', function(event, ins) {
|
||||
return op.forwardEvent(this, 'change', ins);
|
||||
});
|
||||
return this.on('delete', (function(_this) {
|
||||
return function(event, ins, del) {
|
||||
var _ref;
|
||||
return (_ref = _this.replace_manager) != null ? _ref.forwardEvent(_this, 'change', del) : void 0;
|
||||
return op.forwardEvent(_this, 'change', del);
|
||||
};
|
||||
})(this));
|
||||
};
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1 +1 @@
|
||||
{"version":3,"sources":["Types/XmlTypes.coffee"],"names":[],"mappings":"AAyGwC;AAAA;AAAA","file":"Types/XmlTypes.js","sourceRoot":"/source/","sourcesContent":[""]}
|
||||
{"version":3,"sources":["Types/XmlTypes.coffee"],"names":[],"mappings":"AA4VkB;AAAA;AAAA","file":"Types/XmlTypes.js","sourceRoot":"/source/","sourcesContent":[""]}
|
||||
Reference in New Issue
Block a user