Skip to content

Commit 525f249

Browse files
committed
added default detection for update-update the same AND delete-move
1 parent 0ee145a commit 525f249

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

src/customisable/defaultConflictDetection.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@ import { CustomOp, DifferenceOperationKind } from "../interfaces/util.js";
33
import { DiffWithUsedFlag } from "../interfaces/inputmodels.js";
44
import { isDeepStrictEqual } from "node:util";
55

6+
7+
export function isUpdateUpdateTheSameConflict(
8+
diffL: DiffWithUsedFlag,
9+
diffR: DiffWithUsedFlag,
10+
): boolean {
11+
12+
if (isDeepStrictEqual(diffL.opInfo.value, diffR.opInfo.value)) {
13+
return true;
14+
}
15+
16+
return false;
17+
}
18+
19+
620
/*
721
both directions
822
*/
@@ -107,3 +121,27 @@ export function isMoveMoveConflict(
107121

108122
// dann hab ich die zusammengehörigen Operations für move => delete und add
109123
}
124+
125+
126+
// special case if ref target got deleted
127+
export function isDeleteMoveConflict(
128+
operationLeft: CustomOp,
129+
operationRight: CustomOp,
130+
): boolean {
131+
132+
// TODO
133+
if (
134+
operationLeft.op === DifferenceOperationKind.MOVE
135+
) {
136+
if (directRefExists(operationRight.path, operationLeft.value as object)) {
137+
return true;
138+
}
139+
} else if (
140+
operationRight.op === DifferenceOperationKind.MOVE
141+
) {
142+
if (directRefExists(operationLeft.path, operationRight.value as object)) {
143+
return true;
144+
}
145+
}
146+
return false;
147+
}

0 commit comments

Comments
 (0)