findDupsById method
TwoLists<CalibreWeebi<ArticleRawAbstract> >
findDupsById({
- required List<
CalibreWeebi< newList,ArticleRawAbstract> >
Implementation
TwoLists<CalibreWeebi> findDupsById({required List<CalibreWeebi> newList}) {
final noDups = <CalibreWeebi>[];
final dups = <CalibreWeebi>[];
if (isEmpty) {
noDups.addAll(newList);
return TwoLists<CalibreWeebi>(dups: dups, noDups: noDups);
}
final oldListIds = map((e) => e.id);
final newListIds = newList.map((e) => e.id);
for (final newId in newListIds) {
if (oldListIds.contains(newId)) {
dups.add(newList.firstWhere((e) => e.id == newId));
} else {
noDups.add(newList.firstWhere((e) => e.id == newId));
}
}
return TwoLists(noDups: noDups, dups: dups);
}