2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-05-02 07:26:50 +00:00

Fixed "await" for refreshable states

- Progress indicator stays in place until calls are completed
This commit is contained in:
Oliver Walters 2021-02-07 09:43:07 +11:00
parent 0cfac69d16
commit 12f4a4fa38
4 changed files with 18 additions and 21 deletions

View File

@ -62,7 +62,7 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
int pk = category?.pk ?? -1;
// Request a list of sub-categories under this one
InvenTreePartCategory().list(context, filters: {"parent": "$pk"}).then((var cats) {
await InvenTreePartCategory().list(context, filters: {"parent": "$pk"}).then((var cats) {
_subcategories.clear();
for (var cat in cats) {
@ -76,7 +76,7 @@ class _CategoryDisplayState extends RefreshableState<CategoryDisplayWidget> {
});
// Request a list of parts under this category
InvenTreePart().list(context, filters: {"category": "$pk"}).then((var parts) {
await InvenTreePart().list(context, filters: {"category": "$pk"}).then((var parts) {
_parts.clear();
for (var part in parts) {

View File

@ -60,7 +60,7 @@ class _CompanyListState extends RefreshableState<CompanyListWidget> {
@override
Future<void> request(BuildContext context) async {
InvenTreeCompany().list(context, filters: _filters).then((var companies) {
await InvenTreeCompany().list(context, filters: _filters).then((var companies) {
_companies.clear();

View File

@ -68,7 +68,7 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
int pk = location?.pk ?? -1;
// Request a list of sub-locations under this one
InvenTreeStockLocation().list(context, filters: {"parent": "$pk"}).then((var locs) {
await InvenTreeStockLocation().list(context, filters: {"parent": "$pk"}).then((var locs) {
_sublocations.clear();
for (var loc in locs) {
@ -76,23 +76,21 @@ class _LocationDisplayState extends RefreshableState<LocationDisplayWidget> {
_sublocations.add(loc);
}
}
setState(() {});
// Request a list of stock-items under this one
InvenTreeStockItem().list(context, filters: {"location": "$pk"}).then((var items) {
_items.clear();
for (var item in items) {
if (item is InvenTreeStockItem) {
_items.add(item);
}
}
setState(() {});
});
});
setState(() {});
await InvenTreeStockItem().list(context, filters: {"location": "$pk"}).then((var items) {
_items.clear();
for (var item in items) {
if (item is InvenTreeStockItem) {
_items.add(item);
}
}
});
setState(() {});
}
Widget locationDescriptionCard() {

View File

@ -46,7 +46,6 @@ class _PartStockDisplayState extends RefreshableState<PartStockDetailWidget> {
await part.reload(context);
await part.getStockItems(context);
print("request");
setState(() {
});
}