mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-12-18 10:52:34 +01:00
Merge branch 'soru/verification-dialog' into 'main'
fix: Show bootstrap dialog in the appropriate places See merge request famedly/fluffychat!549
This commit is contained in:
commit
8a021cdc90
@ -2,12 +2,10 @@ import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
||||
import 'package:matrix/encryption/utils/key_verification.dart';
|
||||
import 'package:matrix/matrix.dart';
|
||||
import 'package:matrix_link_text/link_text.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import 'package:fluffychat/pages/key_verification/key_verification_dialog.dart';
|
||||
import 'package:fluffychat/utils/matrix_sdk_extensions.dart/event_extension.dart';
|
||||
import 'package:fluffychat/utils/matrix_sdk_extensions.dart/matrix_locals.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
@ -15,6 +13,7 @@ import '../../../config/app_config.dart';
|
||||
import '../../../pages/video_viewer/video_viewer.dart';
|
||||
import '../../../utils/platform_infos.dart';
|
||||
import '../../../utils/url_launcher.dart';
|
||||
import '../../bootstrap/bootstrap_dialog.dart';
|
||||
import 'audio_player.dart';
|
||||
import 'html_message.dart';
|
||||
import 'image_bubble.dart';
|
||||
@ -44,22 +43,12 @@ class MessageContent extends StatelessWidget {
|
||||
}
|
||||
final client = Matrix.of(context).client;
|
||||
if (client.isUnknownSession && client.encryption.crossSigning.enabled) {
|
||||
final req =
|
||||
await client.userDeviceKeys[client.userID].startVerification();
|
||||
req.onUpdate = () async {
|
||||
if (req.state == KeyVerificationState.done) {
|
||||
for (var i = 0; i < 12; i++) {
|
||||
if (await client.encryption.keyManager.isCached()) {
|
||||
break;
|
||||
}
|
||||
await Future.delayed(const Duration(seconds: 1));
|
||||
}
|
||||
final timeline = await event.room.getTimeline();
|
||||
timeline.requestKeys();
|
||||
timeline.cancelSubscriptions();
|
||||
}
|
||||
};
|
||||
await KeyVerificationDialog(request: req).show(context);
|
||||
await BootstrapDialog(
|
||||
client: Matrix.of(context).client,
|
||||
).show(context);
|
||||
final timeline = await event.room.getTimeline();
|
||||
timeline.requestKeys();
|
||||
timeline.cancelSubscriptions();
|
||||
} else {
|
||||
final success = await showFutureLoadingDialog(
|
||||
context: context,
|
||||
|
@ -92,25 +92,7 @@ class SettingsSecurityController extends State<SettingsSecurity> {
|
||||
}
|
||||
}
|
||||
|
||||
void bootstrapSettingsAction() async {
|
||||
if (await Matrix.of(context).client.encryption.keyManager.isCached()) {
|
||||
if (OkCancelResult.ok ==
|
||||
await showOkCancelAlertDialog(
|
||||
useRootNavigator: false,
|
||||
context: context,
|
||||
title: L10n.of(context).keysCached,
|
||||
message: L10n.of(context).wipeChatBackup,
|
||||
isDestructiveAction: true,
|
||||
okLabel: L10n.of(context).ok,
|
||||
cancelLabel: L10n.of(context).cancel,
|
||||
)) {
|
||||
await BootstrapDialog(
|
||||
client: Matrix.of(context).client,
|
||||
wipe: true,
|
||||
).show(context);
|
||||
}
|
||||
return;
|
||||
}
|
||||
void showBootstrapDialog(BuildContext context) async {
|
||||
await BootstrapDialog(
|
||||
client: Matrix.of(context).client,
|
||||
).show(context);
|
||||
|
@ -67,6 +67,10 @@ class SettingsSecurityView extends StatelessWidget {
|
||||
Matrix.of(context).client.encryption.crossSigning.enabled
|
||||
? const Icon(Icons.check, color: Colors.green)
|
||||
: const Icon(Icons.error, color: Colors.red),
|
||||
onTap:
|
||||
Matrix.of(context).client.encryption.crossSigning.enabled
|
||||
? null
|
||||
: () => controller.showBootstrapDialog(context),
|
||||
),
|
||||
ListTile(
|
||||
title: Text(L10n.of(context).onlineKeyBackupEnabled),
|
||||
@ -74,24 +78,40 @@ class SettingsSecurityView extends StatelessWidget {
|
||||
Matrix.of(context).client.encryption.keyManager.enabled
|
||||
? const Icon(Icons.check, color: Colors.green)
|
||||
: const Icon(Icons.error, color: Colors.red),
|
||||
onTap: Matrix.of(context).client.encryption.keyManager.enabled
|
||||
? null
|
||||
: () => controller.showBootstrapDialog(context),
|
||||
),
|
||||
ListTile(
|
||||
title: const Text('Session verified'),
|
||||
trailing: !Matrix.of(context).client.isUnknownSession
|
||||
? const Icon(Icons.check, color: Colors.green)
|
||||
: const Icon(Icons.error, color: Colors.red),
|
||||
onTap: !Matrix.of(context).client.isUnknownSession
|
||||
? null
|
||||
: () => controller.showBootstrapDialog(context),
|
||||
),
|
||||
FutureBuilder(
|
||||
future: Matrix.of(context)
|
||||
.client
|
||||
.encryption
|
||||
.keyManager
|
||||
.isCached(),
|
||||
future: () async {
|
||||
return (await Matrix.of(context)
|
||||
.client
|
||||
.encryption
|
||||
.keyManager
|
||||
.isCached()) &&
|
||||
(await Matrix.of(context)
|
||||
.client
|
||||
.encryption
|
||||
.crossSigning
|
||||
.isCached());
|
||||
}(),
|
||||
builder: (context, snapshot) => ListTile(
|
||||
title: Text(L10n.of(context).keysCached),
|
||||
trailing: snapshot.data == true
|
||||
? const Icon(Icons.check, color: Colors.green)
|
||||
: const Icon(Icons.error, color: Colors.red),
|
||||
onTap: snapshot.data == true
|
||||
? null
|
||||
: () => controller.showBootstrapDialog(context),
|
||||
),
|
||||
),
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user