Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/smooth_app/lib/database/dao_product.dart
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ class DaoProduct extends AbstractSqlDao implements BulkDeletable {

Future<List<String>> getAllKeys() async {
final List<String> result = <String>[];
final Set<String> excluded = excludeBarcodes.toSet();
final List<Map<String, dynamic>> queryResults = await localDatabase.database
.query(
_TABLE_PRODUCT,
Expand Down Expand Up @@ -433,7 +434,7 @@ class DaoProduct extends AbstractSqlDao implements BulkDeletable {
while (await queryCursor.moveNext()) {
final String barcode =
queryCursor.current[_TABLE_PRODUCT_COLUMN_BARCODE]! as String;
if (excludeBarcodes.contains(barcode)) {
if (excluded.contains(barcode)) {
continue;
}
String? foundProductType =
Expand Down
27 changes: 12 additions & 15 deletions packages/smooth_app/lib/database/dao_product_list.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:async';
import 'dart:convert';
import 'dart:collection';

import 'package:hive_flutter/hive_flutter.dart';
import 'package:openfoodfacts/openfoodfacts.dart';
Expand Down Expand Up @@ -235,28 +236,24 @@ class DaoProductList extends AbstractDao {
final bool include = true,
}) async {
final _BarcodeList? list = await _get(productList);
final List<String> allBarcodes;

final LinkedHashSet<String> allBarcodes;
if (list == null) {
allBarcodes = <String>[];
allBarcodes = LinkedHashSet<String>();
} else {
allBarcodes = _getSafeBarcodeListCopy(list.barcodes);
allBarcodes = LinkedHashSet<String>.from(list.barcodes);
}

for (final String barcode in barcodes) {
if (include) {
if (!allBarcodes.contains(barcode)) {
allBarcodes.add(barcode);
}
} else {
if (allBarcodes.contains(barcode)) {
allBarcodes.remove(barcode);
}
}
if (include) {
allBarcodes.add(barcode);
} else {
allBarcodes.remove(barcode);
}
}
}

final _BarcodeList newList = _BarcodeList.now(allBarcodes);
await _put(getKey(productList), newList);
final _BarcodeList newList =
_BarcodeList.now(allBarcodes.toList());
}

Future<ProductList> rename(
Expand Down
Loading