check static method
Implementation
static ConflictModel? check(JsonMapList mine, JsonMapList yours) {
// 1. Get local (mine) and remote (yours) patches
final yourPaths = yours.map((op) => op['path']);
final concurrent = mine.where((op) => yourPaths.contains(op['path']));
// 2. Check if any of mine and yours patches collide
final eq = const MapEquality().equals;
final conflicts = concurrent.where(
(op1) => yours
.where((op2) => op2['path'] == op1['path'] && !eq(op1, op2))
.isNotEmpty,
);
return conflicts.isNotEmpty
? ConflictModel(
type: ConflictType.merge,
mine: mine,
yours: yours,
paths: conflicts.map((op) => op['path'] as String).toList(),
)
: null;
}