fix: Missing null check and bootstrap ask

This commit is contained in:
Christian Pauly 2021-08-01 15:45:41 +02:00
parent bb7c095ae3
commit 0135780f65
4 changed files with 31 additions and 2 deletions

View File

@ -903,6 +903,11 @@
"type": "text",
"placeholders": {}
},
"dontAskAgain": "Cancel and don't ask again",
"@dontAskAgain": {
"type": "text",
"placeholders": {}
},
"encrypted": "Encrypted",
"@encrypted": {
"type": "text",

View File

@ -18,4 +18,6 @@ abstract class SettingKeys {
static const String unifiedPushEndpoint = 'chat.fluffy.unifiedpush.endpoint';
static const String notificationCurrentIds = 'chat.fluffy.notification_ids';
static const String ownStatusMessage = 'chat.fluffy.status_msg';
static const String dontAskForBootstrapKey =
'chat.fluffychat.dont_ask_bootstrap';
}

View File

@ -1,4 +1,6 @@
import 'package:adaptive_dialog/adaptive_dialog.dart';
import 'package:fluffychat/config/setting_keys.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions.dart/flutter_matrix_hive_database.dart';
import 'package:matrix/encryption.dart';
import 'package:matrix/encryption/utils/bootstrap.dart';
import 'package:matrix/matrix.dart';
@ -65,6 +67,12 @@ class _BootstrapDialogState extends State<BootstrapDialog> {
});
}
void cancelAndDontAskAgain() async {
await (widget.client.database as FlutterMatrixHiveStore)
.put(SettingKeys.dontAskForBootstrapKey, true);
Navigator.of(context, rootNavigator: false).pop<bool>(false);
}
@override
Widget build(BuildContext context) {
_wipe ??= widget.wipe;
@ -81,6 +89,11 @@ class _BootstrapDialogState extends State<BootstrapDialog> {
label: L10n.of(context).next,
onPressed: () => _createBootstrap(false),
));
buttons.add(AdaptiveFlatButton(
label: L10n.of(context).dontAskAgain,
onPressed: cancelAndDontAskAgain,
textColor: Colors.red,
));
} else if (bootstrap.newSsssKey?.recoveryKey != null &&
_recoveryKeyStored == false) {
final key = bootstrap.newSsssKey.recoveryKey;

View File

@ -2,6 +2,8 @@ import 'dart:async';
import 'dart:io';
import 'package:adaptive_dialog/adaptive_dialog.dart';
import 'package:fluffychat/config/setting_keys.dart';
import 'package:fluffychat/utils/matrix_sdk_extensions.dart/flutter_matrix_hive_database.dart';
import 'package:matrix/matrix.dart';
import 'package:fluffychat/utils/fluffy_share.dart';
@ -156,6 +158,11 @@ class ChatListController extends State<ChatList> {
_initReceiveSharingIntent();
WidgetsBinding.instance.addPostFrameCallback((_) async {
if (!Matrix.of(context).client.encryptionEnabled) return;
if ((Matrix.of(context).client.database as FlutterMatrixHiveStore)
.get(SettingKeys.dontAskForBootstrapKey) ==
true) {
return;
}
final crossSigning = await crossSigningCachedFuture;
final needsBootstrap =
Matrix.of(context).client.encryption?.crossSigning?.enabled ==
@ -181,10 +188,12 @@ class ChatListController extends State<ChatList> {
if (room.isSpace) return false;
if (activeSpaceId != null) {
final space = Matrix.of(context).client.getRoomById(activeSpaceId);
if (space.spaceChildren.any((child) => child.roomId == room.id)) {
if (space.spaceChildren?.any((child) => child.roomId == room.id) ??
false) {
return true;
}
if (room.spaceParents.any((parent) => parent.roomId == activeSpaceId)) {
if (room.spaceParents?.any((parent) => parent.roomId == activeSpaceId) ??
false) {
return true;
}
if (room.isDirectChat &&