mirror of
https://gitlab.com/veilid/veilidchat.git
synced 2025-08-15 01:15:42 -04:00
fix deadlock
clean up async handling improve styled alerts
This commit is contained in:
parent
22390f31ff
commit
8edccb8a0f
21 changed files with 125 additions and 108 deletions
|
@ -8,7 +8,7 @@ import '../../proto/proto.dart' as proto;
|
|||
import '../account_manager.dart';
|
||||
|
||||
typedef AccountRecordState = proto.Account;
|
||||
typedef _sspUpdateState = (
|
||||
typedef _SspUpdateState = (
|
||||
AccountSpec accountSpec,
|
||||
Future<void> Function() onSuccess
|
||||
);
|
||||
|
@ -96,5 +96,5 @@ class AccountRecordCubit extends DefaultDHTRecordCubit<AccountRecordState> {
|
|||
}
|
||||
}
|
||||
|
||||
final _sspUpdate = SingleStateProcessor<_sspUpdateState>();
|
||||
final _sspUpdate = SingleStateProcessor<_SspUpdateState>();
|
||||
}
|
||||
|
|
|
@ -24,13 +24,13 @@ class PerAccountCollectionBlocMapCubit extends BlocMapCubit<TypedKey,
|
|||
// Add account record cubit
|
||||
Future<void> _addPerAccountCollectionCubit(
|
||||
{required TypedKey superIdentityRecordKey}) async =>
|
||||
add(() => MapEntry(
|
||||
add(
|
||||
superIdentityRecordKey,
|
||||
PerAccountCollectionCubit(
|
||||
() async => PerAccountCollectionCubit(
|
||||
locator: _locator,
|
||||
accountInfoCubit: AccountInfoCubit(
|
||||
accountRepository: _accountRepository,
|
||||
superIdentityRecordKey: superIdentityRecordKey))));
|
||||
superIdentityRecordKey: superIdentityRecordKey)));
|
||||
|
||||
/// StateFollower /////////////////////////
|
||||
|
||||
|
|
|
@ -78,13 +78,13 @@ class PerAccountCollectionCubit extends Cubit<PerAccountCollectionState> {
|
|||
await _accountRecordSubscription?.cancel();
|
||||
_accountRecordSubscription = null;
|
||||
|
||||
// Update state to 'loading'
|
||||
nextState = _updateAccountRecordState(nextState, null);
|
||||
emit(nextState);
|
||||
|
||||
// Close AccountRecordCubit
|
||||
await accountRecordCubit?.close();
|
||||
accountRecordCubit = null;
|
||||
|
||||
// Update state to 'loading'
|
||||
nextState = _updateAccountRecordState(nextState, null);
|
||||
emit(nextState);
|
||||
} else {
|
||||
///////////////// Logged in ///////////////////
|
||||
|
||||
|
|
|
@ -120,22 +120,22 @@ class _EditAccountPageState extends WindowSetupState<EditAccountPage> {
|
|||
try {
|
||||
final success = await AccountRepository.instance.deleteLocalAccount(
|
||||
widget.superIdentityRecordKey, widget.accountRecord);
|
||||
if (success && mounted) {
|
||||
context
|
||||
.read<NotificationsCubit>()
|
||||
.info(text: translate('edit_account_page.account_removed'));
|
||||
GoRouterHelper(context).pop();
|
||||
} else if (mounted) {
|
||||
context
|
||||
.read<NotificationsCubit>()
|
||||
.error(text: translate('edit_account_page.failed_to_remove'));
|
||||
if (mounted) {
|
||||
if (success) {
|
||||
context
|
||||
.read<NotificationsCubit>()
|
||||
.info(text: translate('edit_account_page.account_removed'));
|
||||
GoRouterHelper(context).pop();
|
||||
} else {
|
||||
context
|
||||
.read<NotificationsCubit>()
|
||||
.error(text: translate('edit_account_page.failed_to_remove'));
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isInAsyncCall = false;
|
||||
});
|
||||
}
|
||||
setState(() {
|
||||
_isInAsyncCall = false;
|
||||
});
|
||||
}
|
||||
} on Exception catch (e, st) {
|
||||
if (mounted) {
|
||||
|
@ -188,22 +188,21 @@ class _EditAccountPageState extends WindowSetupState<EditAccountPage> {
|
|||
try {
|
||||
final success = await AccountRepository.instance.destroyAccount(
|
||||
widget.superIdentityRecordKey, widget.accountRecord);
|
||||
if (success && mounted) {
|
||||
context
|
||||
.read<NotificationsCubit>()
|
||||
.info(text: translate('edit_account_page.account_destroyed'));
|
||||
GoRouterHelper(context).pop();
|
||||
} else if (mounted) {
|
||||
context
|
||||
.read<NotificationsCubit>()
|
||||
.error(text: translate('edit_account_page.failed_to_destroy'));
|
||||
if (mounted) {
|
||||
if (success) {
|
||||
context
|
||||
.read<NotificationsCubit>()
|
||||
.info(text: translate('edit_account_page.account_destroyed'));
|
||||
GoRouterHelper(context).pop();
|
||||
} else {
|
||||
context.read<NotificationsCubit>().error(
|
||||
text: translate('edit_account_page.failed_to_destroy'));
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isInAsyncCall = false;
|
||||
});
|
||||
}
|
||||
setState(() {
|
||||
_isInAsyncCall = false;
|
||||
});
|
||||
}
|
||||
} on Exception catch (e, st) {
|
||||
if (mounted) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue