diff --git a/lib/account_manager/cubits/active_local_account_cubit.dart b/lib/account_manager/cubits/active_local_account_cubit.dart index bc28a92..29a76c9 100644 --- a/lib/account_manager/cubits/active_local_account_cubit.dart +++ b/lib/account_manager/cubits/active_local_account_cubit.dart @@ -3,6 +3,7 @@ import 'dart:async'; import 'package:bloc/bloc.dart'; import 'package:veilid_support/veilid_support.dart'; +import '../../init.dart'; import '../repository/account_repository/account_repository.dart'; class ActiveLocalAccountCubit extends Cubit { @@ -11,6 +12,12 @@ class ActiveLocalAccountCubit extends Cubit { super(null) { // Subscribe to streams _initAccountRepositorySubscription(); + + // Initialize when we can + Future.delayed(Duration.zero, () async { + await eventualInitialized.future; + emit(_accountRepository.getActiveLocalAccount()); + }); } void _initAccountRepositorySubscription() { diff --git a/lib/account_manager/cubits/local_accounts_cubit.dart b/lib/account_manager/cubits/local_accounts_cubit.dart index 457b8ba..376c810 100644 --- a/lib/account_manager/cubits/local_accounts_cubit.dart +++ b/lib/account_manager/cubits/local_accounts_cubit.dart @@ -3,6 +3,7 @@ import 'dart:async'; import 'package:bloc/bloc.dart'; import 'package:fast_immutable_collections/fast_immutable_collections.dart'; +import '../../init.dart'; import '../models/models.dart'; import '../repository/account_repository/account_repository.dart'; @@ -12,6 +13,12 @@ class LocalAccountsCubit extends Cubit> { super(IList()) { // Subscribe to streams _initAccountRepositorySubscription(); + + // Initialize when we can + Future.delayed(Duration.zero, () async { + await eventualInitialized.future; + emit(_accountRepository.getLocalAccounts()); + }); } void _initAccountRepositorySubscription() { diff --git a/lib/account_manager/cubits/user_logins_cubit.dart b/lib/account_manager/cubits/user_logins_cubit.dart index 56dbab5..30269c1 100644 --- a/lib/account_manager/cubits/user_logins_cubit.dart +++ b/lib/account_manager/cubits/user_logins_cubit.dart @@ -3,6 +3,7 @@ import 'dart:async'; import 'package:bloc/bloc.dart'; import 'package:fast_immutable_collections/fast_immutable_collections.dart'; +import '../../init.dart'; import '../models/models.dart'; import '../repository/account_repository/account_repository.dart'; @@ -12,6 +13,12 @@ class UserLoginsCubit extends Cubit> { super(IList()) { // Subscribe to streams _initAccountRepositorySubscription(); + + // Initialize when we can + Future.delayed(Duration.zero, () async { + await eventualInitialized.future; + emit(_accountRepository.getUserLogins()); + }); } void _initAccountRepositorySubscription() {