|
|
|
|
@ -524,16 +524,42 @@ export class Batch {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
apply() {
|
|
|
|
|
if (!batches.has(this)) {
|
|
|
|
|
console.warn('wtf', this.id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!async_mode_flag || (!this.is_fork && batches.size === 1)) return;
|
|
|
|
|
|
|
|
|
|
console.log(this.id, batches.size);
|
|
|
|
|
|
|
|
|
|
// if there are multiple batches, we are 'time travelling' —
|
|
|
|
|
// we need to override values with the ones in this batch...
|
|
|
|
|
batch_values = new Map(this.current);
|
|
|
|
|
|
|
|
|
|
var is_earlier = true;
|
|
|
|
|
|
|
|
|
|
// ...and undo changes belonging to other batches
|
|
|
|
|
// that don't coincide with this batch
|
|
|
|
|
for (const batch of batches) {
|
|
|
|
|
if (batch === this) continue;
|
|
|
|
|
if (batch === this) {
|
|
|
|
|
is_earlier = false;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var coincides = false;
|
|
|
|
|
|
|
|
|
|
if (is_earlier) {
|
|
|
|
|
for (const source of batch.current.keys()) {
|
|
|
|
|
if (this.current.has(source)) {
|
|
|
|
|
coincides = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
console.log(batch.id, { coincides });
|
|
|
|
|
|
|
|
|
|
if (!coincides) {
|
|
|
|
|
for (const [source, previous] of batch.previous) {
|
|
|
|
|
if (!batch_values.has(source)) {
|
|
|
|
|
batch_values.set(source, previous);
|
|
|
|
|
@ -541,6 +567,7 @@ export class Batch {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|