@colyseus/schema 3.0.32 → 3.0.34

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1101,8 +1101,14 @@ class ChangeTree {
1101
1101
  operation(op) {
1102
1102
  // operations without index use negative values to represent them
1103
1103
  // this is checked during .encode() time.
1104
- this.changes.operations.push(-op);
1105
- enqueueChangeTree(this.root, this, 'changes');
1104
+ if (this.filteredChanges !== undefined) {
1105
+ this.filteredChanges.operations.push(-op);
1106
+ enqueueChangeTree(this.root, this, 'filteredChanges');
1107
+ }
1108
+ else {
1109
+ this.changes.operations.push(-op);
1110
+ enqueueChangeTree(this.root, this, 'changes');
1111
+ }
1106
1112
  }
1107
1113
  change(index, operation = OPERATION.ADD) {
1108
1114
  const metadata = this.ref.constructor[Symbol.metadata];
@@ -4602,7 +4608,8 @@ function getDecoderStateCallbacks(decoder) {
4602
4608
  }
4603
4609
  }
4604
4610
  }
4605
- else if ((change.op & OPERATION.ADD) === OPERATION.ADD && change.previousValue === undefined) {
4611
+ else if ((change.op & OPERATION.ADD) === OPERATION.ADD &&
4612
+ change.previousValue !== change.value) {
4606
4613
  // triger onAdd
4607
4614
  const addCallbacks = $callbacks[OPERATION.ADD];
4608
4615
  for (let i = addCallbacks?.length - 1; i >= 0; i--) {