chore: Wait for secrets after bootstrap verification

pull/2384/head
Christian Kußowski 2 months ago
parent 22eb82f7d2
commit 02b0fcb8a6
No known key found for this signature in database
GPG Key ID: E067ECD60F1A0652

@ -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<BootstrapDialog> {
},
);
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),

@ -14,7 +14,7 @@ import 'package:fluffychat/widgets/avatar.dart';
import 'package:fluffychat/widgets/future_loading_dialog.dart';
class KeyVerificationDialog extends StatefulWidget {
Future<void> show(BuildContext context) => showAdaptiveDialog(
Future<bool?> show(BuildContext context) => showAdaptiveDialog<bool>(
context: context,
builder: (context) => this,
barrierDismissible: false,
@ -186,9 +186,9 @@ class KeyVerificationPageState extends State<KeyVerificationDialog> {
);
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<KeyVerificationDialog> {
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<KeyVerificationDialog> {
child: Text(
L10n.of(context).close,
),
onPressed: () => Navigator.of(context, rootNavigator: false).pop(),
onPressed: () =>
Navigator.of(context, rootNavigator: false).pop(false),
),
);
break;

Loading…
Cancel
Save