mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-12-26 08:02:34 +01:00
fix: Show bootstrap dialog in the appropriate places
This commit is contained in:
parent
dcfd717c6c
commit
d9342905e8
@ -2,12 +2,10 @@ import 'package:flutter/material.dart';
|
|||||||
|
|
||||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||||
import 'package:future_loading_dialog/future_loading_dialog.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/matrix.dart';
|
||||||
import 'package:matrix_link_text/link_text.dart';
|
import 'package:matrix_link_text/link_text.dart';
|
||||||
import 'package:url_launcher/url_launcher.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/event_extension.dart';
|
||||||
import 'package:fluffychat/utils/matrix_sdk_extensions.dart/matrix_locals.dart';
|
import 'package:fluffychat/utils/matrix_sdk_extensions.dart/matrix_locals.dart';
|
||||||
import 'package:fluffychat/widgets/matrix.dart';
|
import 'package:fluffychat/widgets/matrix.dart';
|
||||||
@ -15,6 +13,7 @@ import '../../../config/app_config.dart';
|
|||||||
import '../../../pages/video_viewer/video_viewer.dart';
|
import '../../../pages/video_viewer/video_viewer.dart';
|
||||||
import '../../../utils/platform_infos.dart';
|
import '../../../utils/platform_infos.dart';
|
||||||
import '../../../utils/url_launcher.dart';
|
import '../../../utils/url_launcher.dart';
|
||||||
|
import '../../bootstrap/bootstrap_dialog.dart';
|
||||||
import 'audio_player.dart';
|
import 'audio_player.dart';
|
||||||
import 'html_message.dart';
|
import 'html_message.dart';
|
||||||
import 'image_bubble.dart';
|
import 'image_bubble.dart';
|
||||||
@ -44,22 +43,12 @@ class MessageContent extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
final client = Matrix.of(context).client;
|
final client = Matrix.of(context).client;
|
||||||
if (client.isUnknownSession && client.encryption.crossSigning.enabled) {
|
if (client.isUnknownSession && client.encryption.crossSigning.enabled) {
|
||||||
final req =
|
await BootstrapDialog(
|
||||||
await client.userDeviceKeys[client.userID].startVerification();
|
client: Matrix.of(context).client,
|
||||||
req.onUpdate = () async {
|
).show(context);
|
||||||
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();
|
final timeline = await event.room.getTimeline();
|
||||||
timeline.requestKeys();
|
timeline.requestKeys();
|
||||||
timeline.cancelSubscriptions();
|
timeline.cancelSubscriptions();
|
||||||
}
|
|
||||||
};
|
|
||||||
await KeyVerificationDialog(request: req).show(context);
|
|
||||||
} else {
|
} else {
|
||||||
final success = await showFutureLoadingDialog(
|
final success = await showFutureLoadingDialog(
|
||||||
context: context,
|
context: context,
|
||||||
|
@ -92,25 +92,7 @@ class SettingsSecurityController extends State<SettingsSecurity> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void bootstrapSettingsAction() async {
|
void showBootstrapDialog(BuildContext context) 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;
|
|
||||||
}
|
|
||||||
await BootstrapDialog(
|
await BootstrapDialog(
|
||||||
client: Matrix.of(context).client,
|
client: Matrix.of(context).client,
|
||||||
).show(context);
|
).show(context);
|
||||||
|
@ -67,6 +67,10 @@ class SettingsSecurityView extends StatelessWidget {
|
|||||||
Matrix.of(context).client.encryption.crossSigning.enabled
|
Matrix.of(context).client.encryption.crossSigning.enabled
|
||||||
? const Icon(Icons.check, color: Colors.green)
|
? const Icon(Icons.check, color: Colors.green)
|
||||||
: const Icon(Icons.error, color: Colors.red),
|
: const Icon(Icons.error, color: Colors.red),
|
||||||
|
onTap:
|
||||||
|
Matrix.of(context).client.encryption.crossSigning.enabled
|
||||||
|
? null
|
||||||
|
: () => controller.showBootstrapDialog(context),
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text(L10n.of(context).onlineKeyBackupEnabled),
|
title: Text(L10n.of(context).onlineKeyBackupEnabled),
|
||||||
@ -74,24 +78,40 @@ class SettingsSecurityView extends StatelessWidget {
|
|||||||
Matrix.of(context).client.encryption.keyManager.enabled
|
Matrix.of(context).client.encryption.keyManager.enabled
|
||||||
? const Icon(Icons.check, color: Colors.green)
|
? const Icon(Icons.check, color: Colors.green)
|
||||||
: const Icon(Icons.error, color: Colors.red),
|
: const Icon(Icons.error, color: Colors.red),
|
||||||
|
onTap: Matrix.of(context).client.encryption.keyManager.enabled
|
||||||
|
? null
|
||||||
|
: () => controller.showBootstrapDialog(context),
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
title: const Text('Session verified'),
|
title: const Text('Session verified'),
|
||||||
trailing: !Matrix.of(context).client.isUnknownSession
|
trailing: !Matrix.of(context).client.isUnknownSession
|
||||||
? const Icon(Icons.check, color: Colors.green)
|
? const Icon(Icons.check, color: Colors.green)
|
||||||
: const Icon(Icons.error, color: Colors.red),
|
: const Icon(Icons.error, color: Colors.red),
|
||||||
|
onTap: !Matrix.of(context).client.isUnknownSession
|
||||||
|
? null
|
||||||
|
: () => controller.showBootstrapDialog(context),
|
||||||
),
|
),
|
||||||
FutureBuilder(
|
FutureBuilder(
|
||||||
future: Matrix.of(context)
|
future: () async {
|
||||||
|
return (await Matrix.of(context)
|
||||||
.client
|
.client
|
||||||
.encryption
|
.encryption
|
||||||
.keyManager
|
.keyManager
|
||||||
.isCached(),
|
.isCached()) &&
|
||||||
|
(await Matrix.of(context)
|
||||||
|
.client
|
||||||
|
.encryption
|
||||||
|
.crossSigning
|
||||||
|
.isCached());
|
||||||
|
}(),
|
||||||
builder: (context, snapshot) => ListTile(
|
builder: (context, snapshot) => ListTile(
|
||||||
title: Text(L10n.of(context).keysCached),
|
title: Text(L10n.of(context).keysCached),
|
||||||
trailing: snapshot.data == true
|
trailing: snapshot.data == true
|
||||||
? const Icon(Icons.check, color: Colors.green)
|
? const Icon(Icons.check, color: Colors.green)
|
||||||
: const Icon(Icons.error, color: Colors.red),
|
: const Icon(Icons.error, color: Colors.red),
|
||||||
|
onTap: snapshot.data == true
|
||||||
|
? null
|
||||||
|
: () => controller.showBootstrapDialog(context),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user