From 02b0fcb8a6afe44f7fc0963b2f9807cccfb3cfc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Ku=C3=9Fowski?= Date: Sun, 23 Nov 2025 09:36:28 +0100 Subject: [PATCH] chore: Wait for secrets after bootstrap verification --- lib/pages/bootstrap/bootstrap_dialog.dart | 31 +++++++++++++++++-- .../key_verification_dialog.dart | 14 +++++---- 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/lib/pages/bootstrap/bootstrap_dialog.dart b/lib/pages/bootstrap/bootstrap_dialog.dart index 3d8a2c2ba..e1cdca0b9 100644 --- a/lib/pages/bootstrap/bootstrap_dialog.dart +++ b/lib/pages/bootstrap/bootstrap_dialog.dart @@ -1,3 +1,5 @@ +import 'dart:async'; + import 'package:flutter/material.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; @@ -419,8 +421,33 @@ class BootstrapDialogState extends State { }, ); if (req.error != null) return; - await KeyVerificationDialog(request: req.result!) - .show(context); + final success = await KeyVerificationDialog( + request: req.result!, + ).show(context); + if (success != true) return; + if (!mounted) return; + + final waitForSecret = Completer(); + final secretsSub = client + .encryption!.ssss.onSecretStored.stream + .listen(( + event, + ) async { + if (await client.encryption!.keyManager + .isCached() && + await client.encryption!.crossSigning + .isCached()) { + waitForSecret.complete(); + } + }); + + final result = await showFutureLoadingDialog( + context: context, + future: () => waitForSecret.future, + ); + await secretsSub.cancel(); + if (!mounted) return; + if (!result.isError) _goBackAction(true); }, ), const SizedBox(height: 16), diff --git a/lib/pages/key_verification/key_verification_dialog.dart b/lib/pages/key_verification/key_verification_dialog.dart index cea371355..3562163c2 100644 --- a/lib/pages/key_verification/key_verification_dialog.dart +++ b/lib/pages/key_verification/key_verification_dialog.dart @@ -14,7 +14,7 @@ import 'package:fluffychat/widgets/avatar.dart'; import 'package:fluffychat/widgets/future_loading_dialog.dart'; class KeyVerificationDialog extends StatefulWidget { - Future show(BuildContext context) => showAdaptiveDialog( + Future show(BuildContext context) => showAdaptiveDialog( context: context, builder: (context) => this, barrierDismissible: false, @@ -186,9 +186,9 @@ class KeyVerificationPageState extends State { ); buttons.add( AdaptiveDialogAction( - onPressed: () => widget.request - .rejectVerification() - .then((_) => Navigator.of(context, rootNavigator: false).pop()), + onPressed: () => widget.request.rejectVerification().then( + (_) => Navigator.of(context, rootNavigator: false).pop(false), + ), child: Text( L10n.of(context).reject, style: TextStyle(color: theme.colorScheme.error), @@ -318,7 +318,8 @@ class KeyVerificationPageState extends State { child: Text( L10n.of(context).close, ), - onPressed: () => Navigator.of(context, rootNavigator: false).pop(), + onPressed: () => + Navigator.of(context, rootNavigator: false).pop(true), ), ); break; @@ -342,7 +343,8 @@ class KeyVerificationPageState extends State { child: Text( L10n.of(context).close, ), - onPressed: () => Navigator.of(context, rootNavigator: false).pop(), + onPressed: () => + Navigator.of(context, rootNavigator: false).pop(false), ), ); break;