Skip to content

Commit

Permalink
fix: openfoodfacts#2362 history not refreshing
Browse files Browse the repository at this point in the history
  • Loading branch information
cli1005 committed Jun 27, 2022
1 parent 3999967 commit 8d7f25f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,11 @@ class ContinuousScanModel with ChangeNotifier {
if (_latestFoundBarcode != product.barcode!) {
_latestFoundBarcode = product.barcode;
_daoProductList.push(productList, _latestFoundBarcode!);
_daoProductList.push(_history, _latestFoundBarcode!);
_daoProductList.push(
_history,
_latestFoundBarcode!,
needNotify: true,
);
}
_setBarcodeState(product.barcode!, state);
}
Expand Down
9 changes: 8 additions & 1 deletion packages/smooth_app/lib/database/dao_product_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,11 @@ class DaoProductList extends AbstractDao {
/// One barcode duplicate is potentially removed:
/// * If the barcode was already there, it's moved to the end of the list.
/// * If the barcode wasn't there, it's added to the end of the list.
void push(final ProductList productList, final String barcode) {
void push(
final ProductList productList,
final String barcode, {
bool needNotify = false,
}) {
final _BarcodeList? list = _get(productList);
final List<String> barcodes;
if (list == null) {
Expand All @@ -195,6 +199,9 @@ class DaoProductList extends AbstractDao {
barcodes.add(barcode);
final _BarcodeList newList = _BarcodeList.now(barcodes);
_put(_getKey(productList), newList);
if (needNotify) {
localDatabase.notifyListeners();
}
}

void clear(final ProductList productList) {
Expand Down

0 comments on commit 8d7f25f

Please sign in to comment.