From 040c18d80fec095a4c6ea715a4e876a51e7332ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Ku=C3=9Fowski?= Date: Tue, 23 Dec 2025 15:36:36 +0100 Subject: [PATCH] fix: Better wait for secrets after verification bootstrap --- lib/pages/bootstrap/bootstrap_dialog.dart | 35 +++++++++++------------ 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/lib/pages/bootstrap/bootstrap_dialog.dart b/lib/pages/bootstrap/bootstrap_dialog.dart index 003ad1bc7..e7fa87032 100644 --- a/lib/pages/bootstrap/bootstrap_dialog.dart +++ b/lib/pages/bootstrap/bootstrap_dialog.dart @@ -1,5 +1,3 @@ -import 'dart:async'; - import 'package:flutter/material.dart'; import 'package:flutter_secure_storage/flutter_secure_storage.dart'; @@ -444,26 +442,25 @@ class BootstrapDialogState extends State { 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, + future: () async { + final allCached = + await client.encryption!.keyManager + .isCached() && + await client.encryption!.crossSigning + .isCached(); + if (!allCached) { + await client + .encryption! + .ssss + .onSecretStored + .stream + .first; + } + return; + }, ); - await secretsSub.cancel(); if (!mounted) return; if (!result.isError) _goBackAction(true); },