mirror of
https://github.com/pd4d10/git-touch.git
synced 2026-04-29 19:13:36 -05:00
fix: empty accounts
This commit is contained in:
@@ -65,15 +65,15 @@ class AuthModel with ChangeNotifier {
|
|||||||
// static final inAppReview = InAppReview.instance;
|
// static final inAppReview = InAppReview.instance;
|
||||||
var hasRequestedReview = false;
|
var hasRequestedReview = false;
|
||||||
|
|
||||||
List<Account>? _accounts;
|
List<Account> _accounts = [];
|
||||||
int? activeAccountIndex;
|
int? activeAccountIndex;
|
||||||
late StreamSubscription<Uri?> _sub;
|
late StreamSubscription<Uri?> _sub;
|
||||||
bool loading = false;
|
bool loading = false;
|
||||||
|
|
||||||
List<Account>? get accounts => _accounts;
|
List<Account>? get accounts => _accounts;
|
||||||
Account? get activeAccount {
|
Account? get activeAccount {
|
||||||
if (activeAccountIndex == null || _accounts == null) return null;
|
if (activeAccountIndex == null || _accounts.isEmpty) return null;
|
||||||
return _accounts![activeAccountIndex!];
|
return _accounts[activeAccountIndex!];
|
||||||
}
|
}
|
||||||
|
|
||||||
String get token => activeAccount!.token;
|
String get token => activeAccount!.token;
|
||||||
@@ -89,7 +89,7 @@ class AuthModel with ChangeNotifier {
|
|||||||
if (activeAccountIndex == index) {
|
if (activeAccountIndex == index) {
|
||||||
activeAccountIndex = null;
|
activeAccountIndex = null;
|
||||||
}
|
}
|
||||||
_accounts!.removeAt(index);
|
_accounts.removeAt(index);
|
||||||
// Save
|
// Save
|
||||||
final prefs = await SharedPreferences.getInstance();
|
final prefs = await SharedPreferences.getInstance();
|
||||||
await prefs.setString(StorageKeys.accounts, json.encode(_accounts));
|
await prefs.setString(StorageKeys.accounts, json.encode(_accounts));
|
||||||
|
|||||||
Reference in New Issue
Block a user