wt1.1.2f fix for 1.1.3
This commit is contained in:
+15
-18
@@ -5,6 +5,7 @@ import 'package:aitrainer_app/service/api.dart';
|
||||
import 'package:aitrainer_app/service/customer_service.dart';
|
||||
import 'package:aitrainer_app/service/exercise_tree_service.dart';
|
||||
import 'package:aitrainer_app/service/exercisetype_service.dart';
|
||||
import 'package:aitrainer_app/service/firebase_api.dart';
|
||||
import 'package:devicelocale/devicelocale.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
@@ -31,7 +32,8 @@ class Session {
|
||||
await AppLocalizations.delegate.load(AppLanguage().appLocal);
|
||||
print (" -- Session: fetch token..");
|
||||
await _fetchToken(_sharedPreferences);
|
||||
await _initializeFlutterFire();
|
||||
print (" -- FireBase init..");
|
||||
await FirebaseApi().initializeFlutterFire();
|
||||
//initDeviceLocale();
|
||||
|
||||
// Create the initialization Future outside of `build`:
|
||||
@@ -42,17 +44,6 @@ class Session {
|
||||
|
||||
}
|
||||
|
||||
// Define an async function to initialize FlutterFire
|
||||
void _initializeFlutterFire() async {
|
||||
try {
|
||||
// Wait for Firebase to initialize and set `_initialized` state to true
|
||||
await Firebase.initializeApp();
|
||||
} catch (e) {
|
||||
// Set `_error` state to true if Firebase initialization fails
|
||||
print("Error initializing Firebase");
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> initDeviceLocale() async {
|
||||
List languages;
|
||||
String currentLocale;
|
||||
@@ -90,10 +81,10 @@ class Session {
|
||||
} else if (responseJson['token'] != null) {
|
||||
prefs.setString(Cache.authTokenKey, responseJson['token']);
|
||||
Cache().authToken = responseJson['token'];
|
||||
Cache().firebaseUid = prefs.get(Cache.firebaseUidKey);
|
||||
if (prefs.get(Cache.customerIdKey) == null) {
|
||||
print("************** Registration");
|
||||
// registration
|
||||
//Navigator.of(context).pushNamed('registration');
|
||||
prefs.setBool(Cache.isRegisteredKey, true);
|
||||
Cache().startPage = "registration";
|
||||
} else {
|
||||
@@ -107,13 +98,19 @@ class Session {
|
||||
prefs.get(Cache.isLoggedInKey) == null ||
|
||||
prefs.get(Cache.isLoggedInKey) == false) {
|
||||
print("************* Login");
|
||||
//Navigator.of(context).pushNamed('login');
|
||||
Cache().startPage = "login";
|
||||
} else {
|
||||
// get API customer
|
||||
customerId = prefs.getInt(Cache.customerIdKey);
|
||||
await CustomerApi().getCustomer(customerId);
|
||||
Cache().startPage = "home";
|
||||
|
||||
// only
|
||||
if ( Cache().firebaseUid == null) {
|
||||
print("************* firebaseUid is null, Login");
|
||||
Cache().startPage = "login";
|
||||
} else {
|
||||
// get API customer
|
||||
customerId = prefs.getInt(Cache.customerIdKey);
|
||||
await CustomerApi().getCustomer(customerId);
|
||||
Cache().startPage = "home";
|
||||
}
|
||||
}
|
||||
|
||||
await ExerciseTypeApi().getExerciseTypes();
|
||||
|
||||
Reference in New Issue
Block a user