Save user+client in Prefs and only background-fetch them on startup

This commit is contained in:
2024-06-17 22:53:03 +02:00
parent c8bc7665f7
commit 5b8a1e86e0
4 changed files with 121 additions and 28 deletions

View File

@@ -101,20 +101,19 @@ void main() async {
final appAuth = AppAuth(); // ensure UserAccount is loaded
if (appAuth.isAuth()) {
try {
print('[INIT] Load User...');
await appAuth.loadUser();
//TODO fallback to cached user (perhaps event use cached client (if exists) directly and only update/load in background)
} catch (exc, trace) {
ApplicationLog.error('Failed to load user (on startup): ' + exc.toString(), trace: trace);
}
try {
print('[INIT] Load Client...');
await appAuth.loadClient();
//TODO fallback to cached client (perhaps event use cached client (if exists) directly and only update/load in background)
} catch (exc, trace) {
ApplicationLog.error('Failed to load user (on startup): ' + exc.toString(), trace: trace);
}
// load user+client in background
() async {
try {
await appAuth.loadUser();
} catch (exc, trace) {
ApplicationLog.error('Failed to load user (background load on startup): ' + exc.toString(), trace: trace);
}
try {
await appAuth.loadClient();
} catch (exc, trace) {
ApplicationLog.error('Failed to load user (background load on startup): ' + exc.toString(), trace: trace);
}
}();
}
if (!Platform.isLinux) {