Skip to content

Commit 56fe3aa

Browse files
committed
enable CausalArray to receive author in shorthand ops like push, pop, etc.
1 parent 4e5a115 commit 56fe3aa

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/data/collections/causal/CausalArray.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -321,22 +321,22 @@ class CausalArray<T> extends BaseCausalCollection<T> implements CausalCollection
321321
this.delete(hash, undefined, author, extraAuth);
322322
}
323323

324-
async push(element: T) {
325-
await this.insertAt(element, this._contents.length);
324+
async push(element: T, author?: Identity, extraAuth?: Authorizer) {
325+
await this.insertAt(element, this._contents.length, author, extraAuth);
326326
}
327327

328-
async pop(): Promise<T> {
328+
async pop(author?: Identity, extraAuth?: Authorizer): Promise<T> {
329329
this.rebuild();
330330
const lastIdx = this._contents.length - 1;
331331
const last = this._contents[lastIdx];
332-
await this.deleteAt(lastIdx);
332+
await this.deleteAt(lastIdx, author, extraAuth);
333333

334334
return last;
335335
}
336336

337-
async concat(elements: T[]) {
337+
async concat(elements: T[], author?: Identity, extraAuth?: Authorizer) {
338338
this.rebuild();
339-
await this.insertManyAt(elements, this._contents.length);
339+
await this.insertManyAt(elements, this._contents.length, author, extraAuth);
340340
}
341341

342342
contents() {
@@ -625,6 +625,8 @@ class CausalArray<T> extends BaseCausalCollection<T> implements CausalCollection
625625
console.log('verification OK')
626626

627627
if (!Verification.checkKeys(usedKeys, op)) {
628+
console.log('usedKeys', Array.from(usedKeys));
629+
console.log('op', Array.from(op.getCausalOps().keys()))
628630
return false;
629631
}
630632

src/data/model/causal/Authorization.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { HashedMap } from 'data/model';
1+
import { HashedMap } from '../immutable/HashedMap';
22
import { HashedSet } from '../immutable/HashedSet';
33
import { MutationOp } from '../mutable/MutationOp';
44

0 commit comments

Comments
 (0)