diff --git a/lib/backend/permissions.dart b/lib/backend/permissions.dart index 0e78859..d5d6f5a 100644 --- a/lib/backend/permissions.dart +++ b/lib/backend/permissions.dart @@ -62,11 +62,11 @@ class ServerPermission { } class RoomPermission { - static int get addArticles { + static int get addShoppingListItems { return oB("0000001"); } - static int get removeArticles { + static int get removeShoppingListItems { return oB("0000010"); } @@ -92,8 +92,8 @@ class RoomPermission { static List get asList { return [ - addArticles, - removeArticles, + addShoppingListItems, + removeShoppingListItems, editRoomContent, changeMeta, ota, diff --git a/lib/backend/request.dart b/lib/backend/request.dart index cbb7ffc..cb966ec 100644 --- a/lib/backend/request.dart +++ b/lib/backend/request.dart @@ -31,6 +31,7 @@ Future postWithCreadentials( required User credentials}) async { Map headers = { "Content-Type": "application/json", + 'Connection': 'keep-alive', 'Authorization': 'Digest name=${credentials.username} server=${target.tag} accountKey=${credentials.password}' }; diff --git a/lib/screens/room/pages/categories.dart b/lib/screens/room/pages/categories.dart index 8617c71..b14fc35 100644 --- a/lib/screens/room/pages/categories.dart +++ b/lib/screens/room/pages/categories.dart @@ -178,6 +178,7 @@ class _RoomCategoriesPageState extends State { credentials: user), onOK: (_) async { // TODO: remove cached category + fetchCategories(); }, after: () { // close popup @@ -232,10 +233,10 @@ class _RoomCategoriesPageState extends State { }); }, ), - floatingActionButton: ((widget.info?.isAdmin ?? false) || + floatingActionButton: (widget.info != null && ((widget.info?.isAdmin ?? false) || (widget.info?.isOwner ?? false) || ((widget.info?.permissions)! & RoomPermission.editRoomContent != - 0)) + 0))) ? FloatingActionButton.extended( icon: const Icon(Icons.add), label: Text(AppLocalizations.of(context)!.newCategoryShort), diff --git a/lib/screens/room/pages/list.dart b/lib/screens/room/pages/list.dart index ef825d8..17fc8a8 100644 --- a/lib/screens/room/pages/list.dart +++ b/lib/screens/room/pages/list.dart @@ -200,12 +200,15 @@ class _ShoppingListPageState extends State { itemBuilder: (context, index) { final item = list[index]; + RoomCategory cat = RoomCategory.other(context); + try { + cat = categories[item.category!]; + }catch(_){} + return ShoppingListItem( name: item.name, description: item.description, - category: (item.category != null) - ? categories[item.category!] - : RoomCategory.other(context), + category: cat, key: Key(item.id.toString()), inCart: item.state != 0, onDismiss: () { @@ -294,10 +297,12 @@ class _ShoppingListPageState extends State { }, ) ]), - floatingActionButton: ((widget.info?.isAdmin ?? false) || - (widget.info?.isOwner ?? false) || - ((widget.info?.permissions)! & RoomPermission.editRoomContent != - 0)) + floatingActionButton: (widget.info != null && + ((widget.info?.isAdmin ?? false) || + (widget.info?.isOwner ?? false) || + ((widget.info?.permissions)! & + RoomPermission.addShoppingListItems != + 0))) ? FloatingActionButton.extended( icon: const Icon(Icons.add), label: Text(AppLocalizations.of(context)!.newItemShort), diff --git a/lib/screens/room/pages/products.dart b/lib/screens/room/pages/products.dart index 1c9fdbd..b0f80d4 100644 --- a/lib/screens/room/pages/products.dart +++ b/lib/screens/room/pages/products.dart @@ -81,10 +81,10 @@ class _RoomProductsPageState extends State { ); }, ), - floatingActionButton: ((widget.info?.isAdmin ?? false) || + floatingActionButton: (widget.info != null && ((widget.info?.isAdmin ?? false) || (widget.info?.isOwner ?? false) || ((widget.info?.permissions)! & RoomPermission.editRoomContent != - 0)) + 0))) ? FloatingActionButton.extended( icon: const Icon(Icons.add), label: Text(AppLocalizations.of(context)!.newProductShort),