2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-17 04:35:26 +00:00

Part detail view is now refreshabel

- lso add a progress dialog when reloading a model object
This commit is contained in:
Oliver Walters
2020-04-15 12:00:26 +10:00
parent 9b14483273
commit 578d54367a
3 changed files with 38 additions and 19 deletions

View File

@ -89,9 +89,30 @@ class InvenTreeModel {
/*
* Reload this object, by requesting data from the server
*/
Future<bool> reload() async {
Future<bool> reload(BuildContext context) async {
var response = await api.get(url, params: defaultGetFilters());
showProgressDialog(context, "Refreshing data", "Refreshing data for ${NAME}");
var response = await api.get(url, params: defaultGetFilters())
.timeout(Duration(seconds: 10))
.catchError((e) {
hideProgressDialog(context);
if (e is TimeoutException) {
showErrorDialog(context, "Timeout", "No response from server");
} else {
showErrorDialog(context, "Error", e.toString());
}
return null;
});
if (response == null) {
return false;
}
hideProgressDialog(context);
if (response.statusCode != 200) {
print("Error retrieving data");