diff --git a/packages/smooth_app/lib/pages/product/new_product_page.dart b/packages/smooth_app/lib/pages/product/new_product_page.dart index 9a364b59841..df8bf9879bf 100644 --- a/packages/smooth_app/lib/pages/product/new_product_page.dart +++ b/packages/smooth_app/lib/pages/product/new_product_page.dart @@ -266,7 +266,7 @@ class _ProductPageState extends State context, {widget.product.barcode!}, ); - if (refreshed != null && refreshed) { + if (refreshed == true) { setState(() {}); } } diff --git a/packages/smooth_app/lib/pages/product_list_user_dialog_helper.dart b/packages/smooth_app/lib/pages/product_list_user_dialog_helper.dart index e0b2b2d86c0..3cab0f5e632 100644 --- a/packages/smooth_app/lib/pages/product_list_user_dialog_helper.dart +++ b/packages/smooth_app/lib/pages/product_list_user_dialog_helper.dart @@ -200,7 +200,7 @@ class ProductListUserDialogHelper { builder: (BuildContext context) => _UserEmptyLists(daoProductList), ); if (newListCreated != null && newListCreated) { - showUserAddProductsDialog(context, barcodes); + return showUserAddProductsDialog(context, barcodes); } return false; } @@ -216,6 +216,8 @@ class ProductListUserDialogHelper { lists: lists.toSet(), selectedLists: selectedLists.toSet(), onListsSubmitted: (Set newSelectedLists) async { + bool hasChanged = false; + for (final String list in lists) { // Nothing changed if (selectedLists.contains(list) && @@ -226,6 +228,7 @@ class ProductListUserDialogHelper { // List got selected if (!selectedLists.contains(list) && newSelectedLists.contains(list)) { + hasChanged = true; await daoProductList.bulkSet( ProductList.user(list), barcodes.toList(), @@ -235,6 +238,7 @@ class ProductListUserDialogHelper { // List got unselected if (selectedLists.contains(list) && !newSelectedLists.contains(list)) { + hasChanged = true; await daoProductList.bulkSet( ProductList.user(list), barcodes.toList(), @@ -242,6 +246,8 @@ class ProductListUserDialogHelper { ); } } + + return hasChanged; }, ), ); @@ -260,7 +266,7 @@ class _UserLists extends StatefulWidget { final Set lists; final Set selectedLists; - final void Function(Set selectedLists) onListsSubmitted; + final Future Function(Set selectedLists) onListsSubmitted; @override State<_UserLists> createState() => _UserListsState(); @@ -285,9 +291,10 @@ class _UserListsState extends State<_UserLists> { negativeAction: _cancelButton(appLocalizations, context), positiveAction: SmoothActionButton( text: appLocalizations.save, - onPressed: () { - widget.onListsSubmitted.call(selectedLists); - Navigator.of(context).pop(); + onPressed: () async { + Navigator.of(context).pop( + await widget.onListsSubmitted(selectedLists), + ); }, ), body: Column(