diff --git a/lib/pages/bootstrap/tom_bootstrap_dialog.dart b/lib/pages/bootstrap/tom_bootstrap_dialog.dart index ab80759f37..9579f56386 100644 --- a/lib/pages/bootstrap/tom_bootstrap_dialog.dart +++ b/lib/pages/bootstrap/tom_bootstrap_dialog.dart @@ -69,8 +69,18 @@ class TomBootstrapDialogState extends State Future _getRecoveryWords() async { return await _getRecoveryWordsInteractor.execute().then( (either) => either.fold( - (failure) => null, - (success) => success.words, + (failure) { + Logs().e( + 'TomBootstrapDialog::_getRecoveryWords(): $failure', + ); + return null; + }, + (success) { + Logs().d( + 'TomBootstrapDialog::_getRecoveryWords(): ${success.words}', + ); + return success.words; + }, ), ); } @@ -86,8 +96,24 @@ class TomBootstrapDialogState extends State _uploadRecoveryKeyState = UploadRecoveryKeyState.checkingRecoveryWork; }); await _getRecoveryKeyState(); - bootstrap = - widget.client.encryption!.bootstrap(onUpdate: (_) => setState(() {})); + if (widget.client.encryption != null) { + WidgetsBinding.instance.addPostFrameCallback((_) async { + bootstrap = widget.client.encryption!.bootstrap( + onUpdate: (_) { + if (mounted) { + setState(() {}); + } + }, + ); + }); + } else { + Logs().e( + 'TomBootstrapDialog::_loadingData(): encryption is null', + ); + setState(() { + _uploadRecoveryKeyState = UploadRecoveryKeyState.uploadError; + }); + } } Future _getRecoveryKeyState() async { @@ -104,14 +130,18 @@ class TomBootstrapDialogState extends State widget.client.isUnknownSession && mounted) { final recoveryWords = await _getRecoveryWords(); if (recoveryWords != null) { - _recoveryWords = recoveryWords; - _uploadRecoveryKeyState = UploadRecoveryKeyState.useExisting; + setState(() { + _recoveryWords = recoveryWords; + _uploadRecoveryKeyState = UploadRecoveryKeyState.useExisting; + }); } else { Logs().d( 'TomBootstrapDialog::_initializeRecoveryKeyState(): no recovery existed then call bootstrap', ); - Navigator.pop(context); - await BootstrapDialog(client: widget.client).show(); + WidgetsBinding.instance.addPostFrameCallback((_) async { + Navigator.pop(context); + await BootstrapDialog(client: widget.client).show(); + }); } } } else { @@ -121,13 +151,15 @@ class TomBootstrapDialogState extends State final recoveryWords = await _getRecoveryWords(); _wipe = recoveryWords != null; if (recoveryWords != null) { - _uploadRecoveryKeyState = UploadRecoveryKeyState.wipeRecovery; + setState(() { + _uploadRecoveryKeyState = UploadRecoveryKeyState.wipeRecovery; + }); } else { - _uploadRecoveryKeyState = UploadRecoveryKeyState.initial; + setState(() { + _uploadRecoveryKeyState = UploadRecoveryKeyState.initial; + }); } } - - setState(() {}); } bool get isDataLoadingState =>