2
0
mirror of https://github.com/inventree/inventree-app.git synced 2025-06-12 10:15:32 +00:00

API refactoring:

- Error if the server version is *older* than the min required version
- Display dialog boxes for different server errors
This commit is contained in:
Oliver Walters
2021-02-02 20:37:54 +11:00
parent cfb3dd6506
commit b69762ff15
8 changed files with 133 additions and 76 deletions

View File

@ -1,3 +1,4 @@
import 'package:flutter/cupertino.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'api.dart';
@ -35,7 +36,7 @@ class InvenTreePreferences {
InvenTreePreferences._internal();
// Load saved login details, and attempt connection
void loadLoginDetails() async {
void loadLoginDetails(BuildContext context) async {
print("Loading login details");
@ -45,10 +46,10 @@ class InvenTreePreferences {
var username = prefs.getString(_USERNAME) ?? '';
var password = prefs.getString(_PASSWORD) ?? '';
await InvenTreeAPI().connectToServer(server, username, password);
await InvenTreeAPI().connectToServer(context, server, username, password);
}
void saveLoginDetails(String server, String username, String password) async {
void saveLoginDetails(BuildContext context, String server, String username, String password) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
@ -57,6 +58,6 @@ class InvenTreePreferences {
await prefs.setString(_PASSWORD, password);
// Reconnect the API
await InvenTreeAPI().connectToServer(server, username, password);
await InvenTreeAPI().connectToServer(context, server, username, password);
}
}