Load profile information on startup
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import 'package:moneymgr_mobile/services/api/auth_api.dart';
|
||||
import 'package:moneymgr_mobile/services/api/server_api.dart';
|
||||
import 'package:riverpod_annotation/riverpod_annotation.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
@ -27,4 +28,18 @@ extension MoneyMgrSharedPreferences on SharedPreferencesWithCache {
|
||||
Future<void> clearServerConfig() async {
|
||||
await remove("serverConfig");
|
||||
}
|
||||
|
||||
AuthInfo? authInfo() {
|
||||
final json = getString("authInfo");
|
||||
if (json != null) return AuthInfo.fromJson(jsonDecode(json));
|
||||
return null;
|
||||
}
|
||||
|
||||
Future<void> setAuthInfo(AuthInfo info) async {
|
||||
await setString("authInfo", jsonEncode(info));
|
||||
}
|
||||
|
||||
Future<void> clearAuthInfo() async {
|
||||
await remove("authInfo");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user