chore: Wait for secrets after bootstrap verification
This commit is contained in:
parent
22eb82f7d2
commit
02b0fcb8a6
2 changed files with 37 additions and 8 deletions
|
|
@ -1,3 +1,5 @@
|
||||||
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||||
|
|
@ -419,8 +421,33 @@ class BootstrapDialogState extends State<BootstrapDialog> {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
if (req.error != null) return;
|
if (req.error != null) return;
|
||||||
await KeyVerificationDialog(request: req.result!)
|
final success = await KeyVerificationDialog(
|
||||||
.show(context);
|
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),
|
const SizedBox(height: 16),
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import 'package:fluffychat/widgets/avatar.dart';
|
||||||
import 'package:fluffychat/widgets/future_loading_dialog.dart';
|
import 'package:fluffychat/widgets/future_loading_dialog.dart';
|
||||||
|
|
||||||
class KeyVerificationDialog extends StatefulWidget {
|
class KeyVerificationDialog extends StatefulWidget {
|
||||||
Future<void> show(BuildContext context) => showAdaptiveDialog(
|
Future<bool?> show(BuildContext context) => showAdaptiveDialog<bool>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (context) => this,
|
builder: (context) => this,
|
||||||
barrierDismissible: false,
|
barrierDismissible: false,
|
||||||
|
|
@ -186,9 +186,9 @@ class KeyVerificationPageState extends State<KeyVerificationDialog> {
|
||||||
);
|
);
|
||||||
buttons.add(
|
buttons.add(
|
||||||
AdaptiveDialogAction(
|
AdaptiveDialogAction(
|
||||||
onPressed: () => widget.request
|
onPressed: () => widget.request.rejectVerification().then(
|
||||||
.rejectVerification()
|
(_) => Navigator.of(context, rootNavigator: false).pop(false),
|
||||||
.then((_) => Navigator.of(context, rootNavigator: false).pop()),
|
),
|
||||||
child: Text(
|
child: Text(
|
||||||
L10n.of(context).reject,
|
L10n.of(context).reject,
|
||||||
style: TextStyle(color: theme.colorScheme.error),
|
style: TextStyle(color: theme.colorScheme.error),
|
||||||
|
|
@ -318,7 +318,8 @@ class KeyVerificationPageState extends State<KeyVerificationDialog> {
|
||||||
child: Text(
|
child: Text(
|
||||||
L10n.of(context).close,
|
L10n.of(context).close,
|
||||||
),
|
),
|
||||||
onPressed: () => Navigator.of(context, rootNavigator: false).pop(),
|
onPressed: () =>
|
||||||
|
Navigator.of(context, rootNavigator: false).pop(true),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|
@ -342,7 +343,8 @@ class KeyVerificationPageState extends State<KeyVerificationDialog> {
|
||||||
child: Text(
|
child: Text(
|
||||||
L10n.of(context).close,
|
L10n.of(context).close,
|
||||||
),
|
),
|
||||||
onPressed: () => Navigator.of(context, rootNavigator: false).pop(),
|
onPressed: () =>
|
||||||
|
Navigator.of(context, rootNavigator: false).pop(false),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue