findDupsPhotosById method

TwoLists<ArticlePhoto> findDupsPhotosById({
  1. required List<ArticlePhoto> newList,
})

Implementation

TwoLists<ArticlePhoto> findDupsPhotosById(
    {required List<ArticlePhoto> newList}) {
  final noDups = <ArticlePhoto>[];
  final dups = <ArticlePhoto>[];
  if (isEmpty) {
    noDups.addAll(newList);
    return TwoLists<ArticlePhoto>(dups: dups, noDups: noDups);
  }
  for (final newItem in newList) {
    if (any((e) => e.calibreId == newItem.calibreId && e.id == newItem.id)) {
      dups.add(newItem);
    } else {
      noDups.add(newItem);
    }
  }
  return TwoLists(noDups: noDups, dups: dups);
}